Problem: E: Red Black Balloons

Story

Homura-chan's dream comes true. It means ICPC Asia regional contest 20xx will be held in Sapporo! Homura-chan has been working hard for the preparation. And finally, it's the previous day of the contest. Homura-chan started to stock balloons to be delivered to contestants who get accepted. However, she noticed that there were only two colors of balloons: red and black.

Problem Statement

ICPC Asia regional contest in Sapporo plans to provide N problems to contestants. Homura-chan is a professional of contest preparation, so she already knows how many contestants would get acceptance for each problem (!!), a_i contestants for the i-th problem. You can assume the prediction is perfectly accurate. Ideally, Homura-chan would assign a distinct color of a balloon to each problem respectively. But you know, she has only two colors red and black now. Thus, Homura-chan comes up with the idea to differentiate the size of balloons in K levels, that is, each problem has a balloon with a distinct pair of (color, size).

Homura-chan now has r_i red balloons with size i (1 \leq i \leq K) and b_j black balloons with size j (1 \leq j \leq K). Suppose we assign a pair (c_i, s_i) of a color c_i (red or black) and a size s_i to the i-th problem, for each i. As noted, we have to assign distinct pairs to each problem, more precisely, (c_i, s_i) \neq (c_j, s_j) holds for i \neq j. Moreover, the number of balloons with (c_i, s_i) must be no less than a_i. In the case that there are no such assignments, Homura-chan can change the size of balloons by her magic power. Note that Homura-chan doesn't know magic to change the color of balloons, so it's impossible.

Your task is to write a program computing the minimum number of balloons whose size is changed by Homura-chan's magic to realize an assignment satisfying the above-mentioned conditions. If there is no way to achieve such an assignment even if Homura-chan changes the size of balloons infinitely, output `-1` instead.

Input


N K
a_1 ... a_N
r_1 ... r_K
b_1 ... b_K


Constraints

* 1 \leq N,K \leq 60
* N \leq 2K
* 1 \leq a_i \leq 50 (1 \leq i \leq N)
* 1 \leq r_j,b_j \leq 50 (1 \leq j \leq K)
* Inputs consist only of integers.



Output

Output the minimum number of balloons whose size is changed to achieve an assignment in a line. If there are no ways to achieve assignments, output `-1` instead.

Sample Input 1


3 2
6 5 4
8 1
7 1


Output for Sample Input 1


3

Homura-chan changes the size of three red balloons from 1 to 2. Then she can assign (black,1) to the problem 1, (red,1) to the problem 2, and (red,2) to the problem 3.

Sample Input 2


2 1
50 50
2
3


Output for Sample Input 2


-1

Sample Input 3


4 3
3 10 28 43
40 18 2
26 7 11


Output for Sample Input 3


5





Example

Input

3 2
6 5 4
8 1
7 1


Output

3

Solution (in CPP):

Solution:
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



#define SIZE 65
#define MAX 3000

struct Info{
	Info(int arg_value){

		value = arg_value;
	}

	bool operator<(const struct Info &arg) const{
		return value > arg.value;
	}
	int value;
};

int N,K;
vector<Info> vec_A,vec_RED,vec_BLACK;
int A[SIZE],RED[SIZE],BLACK[SIZE];
int ruiseki_A[SIZE],ruiseki_RED[SIZE],ruiseki_BLACK[SIZE];
int dp[SIZE][SIZE][3005];


int main(){

	scanf("%d %d",&N,&K);

	int tmp;

	for(int i = 0; i < N; i++){

		scanf("%d",&tmp);
		vec_A.push_back(Info(tmp));
	}

	sort(vec_A.begin(),vec_A.end());

	ruiseki_A[0] = 0;
	for(int i = 1; i <= N; i++){

		A[i] = vec_A[i-1].value;
		ruiseki_A[i] = A[i];
		ruiseki_A[i] += ruiseki_A[i-1];
	}

	for(int i = 0; i < K; i++){

		scanf("%d",&tmp);
		vec_RED.push_back(Info(tmp));
	}

	sort(vec_RED.begin(),vec_RED.end());

	ruiseki_RED[0] = 0;
	for(int i = 1; i <= K; i++){

		RED[i] = vec_RED[i-1].value;
		ruiseki_RED[i] = RED[i];
		ruiseki_RED[i] += ruiseki_RED[i-1];
	}

	for(int i = 0; i < K; i++){

		scanf("%d",&tmp);
		vec_BLACK.push_back(Info(tmp));
	}

	sort(vec_BLACK.begin(),vec_BLACK.end());

	ruiseki_BLACK[0] = 0;
	for(int i = 1; i <= K; i++){

		BLACK[i] = vec_BLACK[i-1].value;
		ruiseki_BLACK[i] = BLACK[i];
		ruiseki_BLACK[i] += ruiseki_BLACK[i-1];
	}

	for(int i = 0; i <= N; i++){
		for(int k = 0; k <= K; k++){
			for(int p = 0; p <= MAX; p++){
				dp[i][k][p] = BIG_NUM;
			}
		}
	}

	dp[0][0][0] = 0;

	for(int i = 1; i <= N; i++){
		for(int r = 0; r <= K; r++){
			for(int num = 0; num <= MAX; num++){

				if(dp[i-1][r][num] == BIG_NUM)continue;

				int add;

				if(r < K){

					add = max(0,A[i]-RED[r+1]);
					dp[i][r+1][num+A[i]] = min(dp[i][r+1][num+A[i]],dp[i-1][r][num]+add);
				}

				if(i-r >= 1 && i-r <= K){

					add = max(0,A[i]-BLACK[i-r]);
					dp[i][r][num] = min(dp[i][r][num],dp[i-1][r][num]+add);
				}
			}
		}
	}

	int ans = BIG_NUM;
	int total_A = ruiseki_A[N];
	int need_red;
	int need_black;

	for(int i = 0; i <= K; i++){
		for(int num = 0; num <= MAX; num++){

			if(dp[N][i][num] == BIG_NUM)continue;

			need_red = num;

			if(ruiseki_RED[K] < need_red){

				continue;
			}

			if(num == total_A){
				ans = min(ans,dp[N][i][num]);
				continue;
			}

			if(N-i < 0 || N-i > K)continue;

			need_black = total_A-num;

			if(ruiseki_BLACK[K] < need_black){

				continue;
			}

			ans = min(ans,dp[N][i][num]);
		}
	}


	if(ans == BIG_NUM){

		printf("-1\n");

	}else{

		printf("%d\n",ans);
	}

	return 0;
}