The Shift Report
Fenwick Mill's safety report has no interest in what the press averaged over a shift. It cares about the worst moment. The hourly readings arrive as one long run, they are grouped into shifts of equal length, and each shift is represented by its single highest reading. The run always divides exactly into whole shifts.
Task: Print each shift's peak reading.
Input
The first line holds an integer k, the number of hours in a shift. The second line holds an integer n, the number of readings, always a multiple of k. Each of the next n lines holds one reading as a whole number.
Output
One line per shift, in the order the readings arrived, each the highest reading in that shift. Shifts lie end to end and share no hours, so there are exactly n / k lines.
Example:
Input:
3
6
1
5
2
8
3
4
Output:
5
8
Sign in to solve this problem
Reading problems is free for everyone — solving them (Run, Submit, and tracking what you've solved) needs an account.
Sign in