Tasks:
 
Task DescriptionDiscussion (0)
Task :: 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!

INPUT:
From the standard input read two integers N and M, representing the number of purchases, and the number of rounds the machine has to perform before being modified again. (1 <= N, M <= 2000). At the begining of the day, Z can set the cash machine to any of the two settings. From the next N lines read N real numbers, with up to two decimal point precision representing the amounts of money for each purchase, each amount will be between 0.01 and 100.00

OUTPUT:
To the standard output write one integer, representing the amount of cents little Z can save

Input:
9 3
0.4
0.4
0.6
0.6
0.6
0.3
0.3
0.3
0.2

Output:
550

Explanation: 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

Input:
5 2
0.50
0.30
0.20
0.80
0.10

Output:
310
Submit Solution
:
:
Available Languages
Task info
Name:z-donalds
Time:0.2 sec.
Memory:16 MB
#Tests:10
AddedBy: admin
Task Ratings
Difficulty:

3.8 (4 votes)
Quality:

5 (4 votes)
Acceptance Rate
Recent Submissions
Fastest Solutions
UserTime
Amtrix 0 s.
crusader 0 s.
Dgleich 0.015 s.
mbalunovic 0.015 s.
RobertGerbicz 0.02 s.
carlosjoa 0.03 s.
Daniel93 0.03 s.
zuzic 0.04 s.
The_Philosopher 0.045 s.
nemanja1990 0.05 s.
Solved By