Orange or Chocolate Candy? (Contest)
Orange or Chocolate Candy? (Contest) medium Time Limit: 2 sec Memory Limit: 128000 kB
Last updated
Orange or Chocolate Candy? (Contest) medium Time Limit: 2 sec Memory Limit: 128000 kB
Last updated
Problem Statement :
Pino is super fond of candies. Today she has A chocolate candies, B orange candies, and C unknown candies. You are also given the happiness she gets after eating a particular candy. She wants to have exactly X chocolate candies and Y orange candies. She can transform an unknown candy into a candy of any type (chocolate or orange). Find the maximum happiness she can attain. Input The first line of input contains 5 integers X, Y, A, B, and C. The second line contains an A integer corresponding to the happiness of the various chocolate candies. The third line contains B integers corresponding to the happiness of the various orange candies. The fourth line contains C integers corresponding to the happiness of the various unknown candies.
Constraints:- 1 <= A, B, C <= 100000 1 <= X <= A 1 <= Y <= B 1 <= happiness of any candy <= 1000000000 (10^9) Output Output a single integer, the maximum happiness Pino can achieve by eating the candies. Example Sample Input 1:- 1 2 2 2 1 2 4 5 1 3
Sample Output 1:- 12
Sample Input 2:- 2 2 2 2 2 8 6 9 1 2 1
Sample Output 2:- 25
Explanation:- Pino eats the 2nd chocolate candy (happiness=4), then eats the 1st orange candy (happiness=4+5=9), then transforms the first unknown candy to orange candy and eats it (happiness=9+3=12)
link: