A farmers market logs every purchase made during one calendar month. Each log entry records the day of the month it happened on, a weekday code for that day (1 = Monday through 7 = Sunday, so a code of 5 always marks a Friday), and the amount spent, given directly in the smallest currency subunit (cents) so no rounding is needed. The market's accountant only reports Friday sales, and only for the first four Fridays of the month: any Friday landing on day 29, 30, or 31 belongs to a fifth, incomplete week and is left out of the report entirely, and so are all non-Friday entries.
Line 1: an integer n, the number of purchase log entries.
Each of the next n lines contains three integers day weekday amountCents: the day of the month (1-31), the weekday code (1-7), and the purchase amount in cents (0 or more).
Exactly four lines, for week 1 through week 4 in that order. Each line has the format week total, where total is the summed purchase amount for that week's Friday (0 if there were none), printed as a plain decimal number with exactly two digits after the point (dollars.cents), for example 2 10.00. A day belongs to week ((day-1)/7)+1 using integer division; any entry with weekday not equal to 5, or whose computed week is 5 or greater, contributes nothing to the report.
Example 1
Input
6 5 5 500 5 5 250 3 3 9999 12 5 1000 19 5 0 26 5 333
Expected
1 7.50 2 10.00 3 0.00 4 3.33
Explanation
Two Friday purchases fall on day 5 (week ((5-1)/7)+1 = 1): 500 + 250 = 750 cents = $7.50. Day 3 is weekday 3 (not Friday) so its 9999 is ignored. Day 12 is a week-2 Friday with 1000 cents = $10.00. Day 19 is a week-3 Friday with 0 cents = $0.00. Day 26 is a week-4 Friday with 333 cents = $3.33. So the four report lines are 1 7.50, 2 10.00, 3 0.00, 4 3.33.
Example 2
Input
3 30 5 700 10 5 150 1 1 9999
Expected
1 0.00 2 1.50 3 0.00 4 0.00
Explanation
Day 30 is weekday 5 (Friday) but its week is ((30-1)/7)+1 = 5, which is excluded, so its 700 cents never counts. Day 10 is a Friday in week ((10-1)/7)+1 = 2, contributing 150 cents = $1.50. Day 1 is weekday 1 (not Friday), so it is ignored. Weeks 1, 3, and 4 have no qualifying purchases at all, so the report is 1 0.00, 2 1.50, 3 0.00, 4 0.00.
Ready to solve this?
Sign in to open the editor, run your code against the sample tests, and submit against the full test suite.
Sign in to solve →