문제1632--Four Gate Push

### 1632: Four Gate Push

실행시간 제한: 10 Sec  메모리사용 제한: 256 MB
제출: 28  통과: 15
[제출] [채점기록] [묻고답하기]

#### 문제 설명

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 example:

#### 출력 설명

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

#### 입력 예시 Copy

500 400 10 20 15
0 0 0 0 0

#### 출력 예시 Copy

95