eolymp
bolt
Попробуйте наш новый интерфейс для отправки задач
Задачи

Four Gate Push

Four Gate Push

Лимит времени 1 секунда
Лимит использования памяти 64 MiB

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 125minerals 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 (0M50000), the amount of minerals you have, G (0G50000), the amount of gas you have, Z (0Z1000), the strength of a zealot in your army, S (0S1000), the strength of a stalker in your army, and E (0E1000), the strength of a sentry in your army. Input is followed by a single line with M = G = Z = S = E = 0, whichs hould 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