10252: CF EDU - Two Pointer Method - Step 3 - H. A-B Knapsack
[Creator : ]
Description
Given $n$ items of weight $A$ and costs $a_1,…,a_n$, and $m$ items of weight $B$ and costs $b_1,…,b_m$.
They fill a knapsack that can withstand a weight of no more than $s$. Determine what the maximum total cost of the items in the knapsack can be.
They fill a knapsack that can withstand a weight of no more than $s$. Determine what the maximum total cost of the items in the knapsack can be.
Input
The first line contains integers $n, m, s, A, B\ (1≤n,m≤10^5,\ 1≤s,A,B≤10^9)$.
The second line contains $n$ integers $a_i\ (1≤a_i≤10^9)$.
The third line contains $m$ integers $b_i\ (1≤b_i≤10^9)$.
The second line contains $n$ integers $a_i\ (1≤a_i≤10^9)$.
The third line contains $m$ integers $b_i\ (1≤b_i≤10^9)$.
Output
Print one number, the maximum total cost of items that can be put into a knapsack.
Sample 1 Input
6 7 23 3 5
7 4 3 1 5 8
10 12 7 3 8 9 7
Sample 1 Output
47