Лимит времени 2000/4000/4000/4000 мс. Лимит памяти 65000/65000/65000/65000 Кб. Question by Ibrahim Mesecan.
Tanker trucks
Mr. Jones has a small dairy production factory.
Everyday he goes through the neighboring farms and
collects milk with his two tanker trucks.
He wants to collect the maximum amount not exceeding his
tanker capacities. And if he can not buy all milk
from a farm, he doesn't want to go to that farm so
that he is not going to spend extra gasoline.
Question:
Write a program that is going to get the capacities of two
tanker trucks and the amount of milk that neighbors can
supply. Then, print the max amount of milk that can
be collected.
Input specification
In the first line, you will be given three integers: The
number of neighboring farms (n) and the capacities of
two tankers (Cap1, Cap2) . Then in the following line,
you will be given n integers where
3 ≤ n ≤ 16, 0 ≤ (Cap1, Cap2) ≤ 1,000 .
and the amount of milk that neighboring farms can
supply are integers between 0 and 100.
Output specification:
Show the max amount of milk that can be collected.
Note: - Each input number
can be used only once.
- From any farm, you can
either buy all the milk or no milk at all.
Sample Input I
6 80 100
30 50 20 30 30 30
|
Sample Input II
6 90 100
30 20 30 30 30 50
|
Sample Output I
170
|
Sample Output II
190
|
Explanation for sample input 1:
The two tankers can hold 80 + 90 = 170 liters.
The first tanker take (30 + 50) liters from two farms.
And the other tanker can collect from the other three
farms (30 + 30 + 30) .
Для отправки решений необходимо выполнить вход.
|