HomeVolumesContestsSectionsForumsUsersPrintHelpAbout

Sections > Exhaustive search & Backtracking > problem:


50840 - Tanker trucks

Guest
• Review clarifications (1)

Section problems

• 50709 - k-ary Strings
• 50708 - Binary Strings
• 50996 - Checkers - the shortest path
• Check-Mate
• 50479 - Bit Compressor
• 50486 - Problems and Programmers
• 50712 - Moon algebra
• 50717 - Hurdle Jumping
• 50840 - Tanker trucks
• 50490 - Across the River
• 50828 - Arranging Time Table
• 51067 - Jumping frog
• 51142 - Jump Min Value
• 51082 - Sum is equal to K - 1
• Post Office Delivery
• 50506 - The Biggest Island
• 50718 - Elevator

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