提示: 欢迎访问OurACM平台。
Problem 1731 Bricks

Accept: 98    Submit: 266
Time Limit: 1000 mSec    Memory Limit : 32768 KB

Problem Description

You want to repair your house,and you have to buy some bricks.You need Ai of 1*i bricks(i=1..5).
But the store that sells bricks only provides 1*5 bricks.And you can cut bricks to get smaller bricks, but you can't glue bricks together to get larger ones.
For example, you can cut a 1x5 brick to get one 1x3 brick and one 1x2 brick,or two 1x2 brick and one 1x1 brick, etc.
Now you want to know the least number of 1*5 bricks you need to repair your house.

Input

There are multiple test cases.
For each case, there are five integer,the ith integer Ai(0<=Ai<=1000) indicating that you need Ai 1*i bricks.

Output

For each test case, output the least number of 1*5 bricks you need to repair your house.

Sample Input

0 0 0 0 0 6 3 1 1 1

Sample Output

0 5

Source

FZU 2009 Summer Training Qualification -- Hero Revival 2

Submit  Back  Status  Discuss