All submissions for this problem are available.
Read problems statements in Mandarin Chinese and Russian.
Andy and Bob are the only two delivery men of Pizza-chef store. Today, the store received N orders. It's known that the amount of tips may be different when handled by different delivery man. More specifically, if Andy takes the ith order, he would be tipped Ai dollars and if Bob takes this order, the tip would be Bi dollars.
They decided that they would distribute the orders among themselves to maximize the total tip money. One order will be handled by only one person. Also, due to time constraints Andy cannot take more than X orders and Bob cannot take more than Y orders. It is guaranteed that X + Y is greater than or equal to N, which means that all the orders can be handled by either Andy or Bob.
Please find out the maximum possible amount of total tip money after processing all the orders.
- The first line contains three integers N, X, Y.
- The second line contains N integers. The ith integer represents Ai.
- The third line contains N integers. The ith integer represents Bi.
- Print a single integer representing the maximum tip money they would receive.
- 1 ≤ N ≤ 105
- 1 ≤ X, Y ≤ N; X + Y ≥ N
- 1 ≤ Ai, Bi ≤ 104
- 1 ≤ N ≤ 20
- 1 ≤ N ≤ 5000
- 1 ≤ N ≤ 105
Input: 5 3 3 1 2 3 4 5 5 4 3 2 1 Output: 21
Bob will take the first three orders (or the first two) and Andy will take the rest (of course).
|Tags||dynamic-programming, greedy, ltime19, simple, tuananh93|
|Time Limit:||1 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.6, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, SCALA, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, PERL6, TEXT, CLOJ, FS|
Fetching successful submissions