For this Question: Sara has two types of apples that have some sweetness level. She has N apples of the first type which costs her P rupees each and M apples of the second type which costs her Q rupees each. She wants to pick apples in such a way that the total sum of sweetness level is equal to or more than X and the total cost is minimum.The first line of input contains 5 integers N, M, P, Q, X separated by spaces. The second line of input contains N Space- separated integers depicting the sweetness level of the first type of apples. The last line of input contains M space- separated integers depicting the sweetness level of the second type of apples.

Sample Input:-
1 <= N, M <= 50000
1 <= X, P, Q <= 1000000000
1 <= Sweetness <= 100000Print the minimum cost required if it is possible to make total sweetness more than X else print -1.Sample Input:-
5 5 1 2 16
1 2 3 4 5
3 2 1 8 7

Sample Output:-
4

Explanation:-
From first type:- 4, 5
From second type:- 8

Sample Input:-
5 5 1 2 100
1 2 3 4 5
1 2 3 4 5

Sample Output:-
-1, I have written this Solution Code: 
import java.util.*;
import java.lang.*;
import java.io.*;

class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner sc = new Scanner(System.in);
	    
		int n = sc.nextInt();
		int m = sc.nextInt();
		int p = sc.nextInt();
		int q = sc.nextInt();
		int x = sc.nextInt();
		int a[] = new int[n];
		int b[] = new int[m];
for(int i=0;i<n;i++){
    a[i]=sc.nextInt();
}
for(int i =0;i<m;i++){b[i]=sc.nextInt();
}
Arrays.sort(a);
Arrays.sort(b);
long pre[]= new long[n];
long suf[] = new long[m];
pre[0]=a[n-1];
for(int i=1;i<n;i++){
    pre[i]=pre[i-1]+a[n-i-1];
}
suf[0]=b[m-1];
for(int i=1;i<m;i++){
    suf[i]=suf[i-1]+b[m-i-1];
}
long ans=100000000000000L;
if(suf[m-1]>=x){
    ans=Math.min(ans,q*m);
}
if(pre[n-1]>=x){
    ans=Math.min(ans,p*n);
}
int j=m-1;
for(int i=0;i<m;i++){
 if(suf[i]>=x){j=i;
ans=Math.min(ans,q*(j+1));
break;}
}
for(int i=0;i<n;i++){
        if(pre[i]>=x){ans=Math.min(ans,p*(i+1));break;}
    while(j >=0 && pre[i] + suf[j]>=x){
        j--;
    }
    if(j!=m-1){j++;}
    if(pre[i]+suf[j]>=x){
    ans=Math.min(ans,p*(i+1)+q*(j+1));}
}
if(ans==100000000000000L){System.out.print(-1);return ;}
System.out.print(ans);

}


}, In this Programming Language: Java, Now tell me if this Code is compilable or not?