No.32 The Melancholy of the Piggy Bank
Problem Statement
Taro always saves his small change, putting his coins into a piggy bank.
Since the contents of the piggy bank have built up to some extent,
Taro has decided to go to the bank and have them exchanged.
The currency of Taro's country consists of \(1000\)-yen bills and coins of \(100\) yen, \(25\) yen, and \(1\) yen.
There are no bills or coins of any other denomination.
Exchanges are as follows:
・\(25\) coins of \(1\) yen into \(1\) coin of \(25\) yen
・\(4\) coins of \(25\) yen into \(1\) coin of \(100\) yen
・\(10\) coins of \(100\) yen into \(1\) \(1000\)-yen bill
Each of these exchanges can be made.
The input gives the number of each type of coin in the piggy bank.
When exchanging so that the number of coins left on hand is minimized,
output the total number of coins Taro has in the end.
Exchanges can be made any number of times with no fee.
Also, the total amount of money must not change before and after an exchange.
Input
L M N
Line \(1\) contains an integer \( L (0 \leq L \leq 1000) \), the number of \(100\)-yen coins.
Line \(2\) contains an integer \( M (0 \leq M \leq 1000) \), the number of \(25\)-yen coins.
Line \(3\) contains an integer \( N (0 \leq N \leq 1000) \), the number of \(1\)-yen coins.
Output
Output the total number of coins.
Print a newline at the end.
Sample
Sample 1
Input
7 20 10
Output
12
Exchanging the \(25\)-yen coins, \(20\) of them, into \(100\)-yen coins, \(5\) of them, and then exchanging \(100\)-yen coins, \(10\) of them, into a \(1000\)-yen bill
gives the minimum.
Sample 2
Input
0 0 0
Output
0
The piggy bank was empty.
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。