PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#GD0000110. Dọn bộ nhớ điện thoại (Cleaning the Phone)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

2 lộ trình

Dọn bộ nhớ điện thoại (Cleaning the Phone)

Cleaning the Phone

Source: Codeforces

Version: Phuoc Hung OJ Extended

Problem Statement

A phone has nn apps; app ii uses aia_i units of memory and uninstalling it loses bi∈{1,2}b_i\in\{1,2\} convenience points. Uninstall a subset to free at least mm memory with minimum total lost points, or print -1 if impossible.

Input

Line 1 contains n,mn,m. Line 2 contains nn memory values aia_i. Line 3 contains nn costs bib_i.

Output

Print the minimum lost convenience or -1.

Subtasks

  • Subtask 1 (20 points): 1≤n≤121\le n\le 12; 1≤m≤1091\le m\le10^9; 1≤ai≤1091\le a_i\le10^9; bi∈{1,2}b_i\in\{1,2\}.
  • Subtask 2 (30 points): 1≤n≤25001\le n\le 2500; 1≤m≤1091\le m\le10^9; 1≤ai≤1091\le a_i\le10^9; bi∈{1,2}b_i\in\{1,2\}.
  • Subtask 3 (50 points): 1≤n≤2000001\le n\le 200000; 1≤m≤1091\le m\le10^9; 1≤ai≤1091\le a_i\le10^9; bi∈{1,2}b_i\in\{1,2\}.

Examples

Input

5 7
5 3 2 1 4
2 1 1 2 1

Output

2

Explanation

Uninstall apps 22 and 55 to free 3+4=73+4=7 memory units at convenience cost 1+1=21+1=2. No cost-11 choice can free 77 memory units.