HomeVolumesContestsSectionsForumsUsersPrintHelpAbout

Volumes > Data Structures > problem:


50840 - Tanker trucks

Guest
• Review clarifications (1)

Volume problems

• 50291 - Postfix Arithmetic Expressions
• 50340 - Game 19
• 50836 - Censored
• 51000 - Book Index
• 50505 - kht Puzzle
• 51076 - Key person
• 51062 - Fish Pond II
• 51067 - Jumping frog
• 50840 - Tanker trucks
• 51080 - Deepest Point
• 51079 - Key person - 2
• 50877 - Friendly Queue
• 51021 - Number of Nodes
• 51044 - Number of Trees
• 50876 - He is my cousin
• 50997 - Dynamic Knights
• 50816 - Largest Sum Path

Feedback

If you notice incorrect translations in Contester, please let author know.

Time limit 2000/4000/4000/4000 ms. Memory limit 65000/65000/65000/65000 Kb.
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:

  1. Each input number can be used only once.
  2. 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).



Для отправки решений необходимо выполнить вход.

www.contester.ru