시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 128 MB40232180.769%

문제

You are working hard on your Protoss builds in StarCraft II, especially the 4 Gate Push. You’ve come upon a tough problem, however, which is how to determine the distribution of zealots, stalkers, and sentries to maximize your army strength. Recall (although you should already know!) that zealots cost 100 minerals and no gas, stalkers cost 125 minerals and 50 gas, and sentries cost 50 minerals and 100 gas. Given your current economy and how much each unit increases your army strength, determine the maximum army strength you can obtain.

입력

The input consists of multiple test cases, one on each line. Each test case has 5 integers M (0 ≤ M ≤ 50,000), the amount of minerals you have, G (0 ≤ G ≤ 50,000), the amount of gas you have, Z (0 ≤ Z ≤ 1,000), the strength of a zealot in your army, S (0 ≤ S ≤ 1,000), the strength of a stalker in your army, and E (0 ≤ E ≤ 1,000), the strength of a sentry in your army. Input is followed by a single line with M = G = Z = S = E = 0, which should not be processed.

출력

For each case, output a single line containing the maximum army strength you can obtain.

예제 입력 1

500 400 10 20 15
0 0 0 0 0

예제 출력 1

95