z-donalds
Mister Little Z has finally found the job of his dreams - to work in McDonalds. Since he is beginner there, he has to work at the cashier.
One day he realized this weird thing. Whenever he charges someone x.yz dollars, he can round the amount to upper or lower whole amount of dollars. For example if the price is 3.33 dollars he can charge 3 or 4 dollars, however if the price is 4.00 dollars he can only charge 4 dollars.
He realized that when he rounds down, for example round 3.33 to 3 dollars, then the guest actually gives to Mister Little Z 3.33 dollars, and little z can keep 33 cents, in other case if he rounded it to 4.00 dollars, the guest would pay 4.00 dollars, but z would give to his boss only 3.33, so he would keep 67 cents.
Mister little Z can modify the cash machine to round up or down whenever he wants, however, once modified, it has to round the numbers the same way for the next M times. Also, at the beginning of the day, little Z has to set the machine on one of the two settings!
Little Z went to his friend who can predict future, and he gave him the list of N purchases that he will receive the next day. Help mister Z earn as much cents as he can!
9 3
0.4
0.4
0.6
0.6
0.6
0.3
0.3
0.3
0.2Output:
550Explanation: First 5 purchases are rounded down. Z gets:
0.4 + 0.4 + 0.6 + 0.6 + 0.6 = 260 cents. Next 4 purchases are rounded up, Z gets: 0.7+0.7+0.7+0.8 = 290. So he gets total of 550
5 2
0.50
0.30
0.20
0.80
0.10Output:
310Submit solution
Coming laterThe grading service will be connected in a later migration step. You can inspect the task and your previous results now.