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

Four Gate Push

Four Gate Push

You are working hard on your Protoss builds in StarCraft II, especially the \textbf{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 \textbf{100} minerals and no gas, stalkers cost \textbf{125}minerals and \textbf{50} gas, and sentries cost \textbf{50} minerals and \textbf{100} gas. Given your current economy and how much each unit increases your army strength, determine the maximum army strength you can obtain. \InputFile The input consists of multiple test cases, one on each line. Each test case has \textbf{5} integers \textbf{M} (\textbf{0} ≤ \textbf{M} ≤ \textbf{50000}), the amount of minerals you have, \textbf{G} (\textbf{0} ≤ \textbf{G} ≤ \textbf{50000}), the amount of gas you have, \textbf{Z} (\textbf{0} ≤ \textbf{Z} ≤ \textbf{1000}), the strength of a zealot in your army, \textbf{S} (\textbf{0} ≤ \textbf{S} ≤ \textbf{1000}), the strength of a stalker in your army, and \textbf{E} (\textbf{0} ≤ \textbf{E} ≤ \textbf{1000}), the strength of a sentry in your army. Input is followed by a single line with \textbf{M = G = Z = S = E = 0}, whichs hould not be processed. \OutputFile For each case, output a single line containing the maximum army strength you can obtain.
Ліміт часу 1 секунда
Ліміт використання пам'яті 64 MiB
Вхідні дані #1
500 400 10 20 15
0 0 0 0 0
Вихідні дані #1
95