A community microgrid operator collects daily energy-output readings, in kilowatt-hours, from several solar sensors scattered across a small solar farm. More than one sensor may log a reading on the same day, in which case the farm's output for that day is the sum of all readings logged on it. It is guaranteed that every day from day 1 through the last day that appears in the log has at least one logged reading — no day in that range is skipped. For every day starting from the 7th day onward, the operator wants a rolling weekly report: the total energy produced on that day and the six days immediately before it, together with the average daily output over that same seven-day window, rounded to exactly two decimal places.
Line 1: an integer m, the number of sensor readings.
Each of the next m lines contains two integers day and amount, meaning a sensor logged amount kWh of output on day number day.
Let D be the largest day value that appears in the log. For every day d from 7 to D (inclusive), in increasing order, print one line with three space-separated values: d total average, where total is the sum of the farm's daily output over days d-6 through d inclusive, and average is total divided by 7, rounded to exactly two decimal places using standard round-half-up rounding, printed with exactly two digits after the decimal point (for example 7.50, not 7.5). If D is less than 7, print nothing.
day.Example 1
Input
8 1 10 2 10 3 10 4 10 5 10 6 10 7 10 8 10
Expected
7 70 10.00 8 70 10.00
Explanation
Every day from 1 to 8 has exactly one 10 kWh reading. For day 7, the window covers days 1-7: total = 7*10 = 70, average = 70/7 = 10.00. For day 8, the window covers days 2-8: total is again 7*10 = 70, average 10.00.
Example 2
Input
9 1 2 2 4 3 6 4 8 5 10 6 12 7 5 7 6 8 1
Expected
7 53 7.57 8 52 7.43
Explanation
Days 1-6 have single readings of 2,4,6,8,10,12 kWh. Day 7 has two readings, 5 and 6, which combine into a day-7 total of 11 kWh. For day 7, the window covers days 1-7: total = 2+4+6+8+10+12+11 = 53, average = 53/7 ≈ 7.5714, rounding to 7.57. For day 8, the window covers days 2-8: total = 4+6+8+10+12+11+1 = 52, average = 52/7 ≈ 7.4286, rounding to 7.43.
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 →