Home | 
Hotel |
Persyaratan | 
Jadwal | 
Peraturan | 
Hadiah | 
Finalist | 
Informasi
|
ACM-ICPC INC 2008 Qualification
Problem E
Lemonade One
Time Limit: 3s
Jack is a big fan of Lemonade Tycoon (computer game). He cleared the game only in 3 days and managed to get the highest score on the game's record two weeks later. Inspired by this game, he decided to start his own lemonade business with his saving money and opens a booth. He named his lemonade booth as Lemonade One.
Preparing lemonade is not as hard as he thought. He needs exactly 3 lemons, 1 block of sugar and 2 ice cubes to make a glass of lemonade. Those ingredients are bought early morning before he sells the lemonades (he won't buy anymore ingredients as he starts to sell lemonade on that particular day). He will not buy any ingredients if he decides not to sell any lemonade on that day. Jack is quite confident that all lemonades will be sold out whenever he tries to sell them, so he never buys ingredients more than what he needs for that day (no ingredients left at the end of the day). He will buy those ingredients by cash, so if he doesn't have enough money to buy, he won't buy.
Altough he's very enthusiastic, Jack doesn't want to spend too much time on this new business. He will choose at most 2 days out of his 5 available days to sell lemonades (he may choose less than 2 days). Every buck that he earns each day can be used to buy more ingredients for any following days. Every day, the price of each ingredient is fluctuating, but he sells the lemonade at a fixed price, 20 bucks for a glass.
Help Jack to find the maximum number of glasses of lemonade that he can sell (he's not interested in the maximum profit)!
Input
The first line of input contains an integer T, the number of test cases follow.
Each test case consists of four lines:
The first line contains an integer P (1 <= P <= 100) the initial amount of money that he has.
The second line contains five integers Li (1 <= Li <= 10) each representing the price for one lemon on i-th day.
The third line contains five integers Si (1 <= Si <= 10) each representing the price for one block of sugar on i-th day.
The fourth line contains five integers Ci (1 <= Ci <= 10) each representing the price for one ice cube on i-th day.
Output
For each test case, output in a line the maximum number of lemonades that he can sell (he may choose at most 2 from 5 days).
Sample Input | Output for Sample Input |
3
50
2 2 3 1 1
1 4 2 2 6
3 5 1 1 3
60
10 10 10 10 1
10 10 10 10 1
10 10 10 10 1
40
10 10 10 10 10
10 10 10 10 10
10 10 10 10 10
| 16
10
0
|
|
|
|