After a regional blackout, every battery bank at a solar micro-grid farm reports its charge level once per recovery day, for exactly five consecutive recovery days numbered 1 through 5 (a given bank's five reports may not arrive in day order in the log). The grid operator wants to certify a bank with a "Steady Rebound" award whenever its charge level never drops from one recovery day to the next across the whole five-day window — that is, its day-1 through day-5 charge readings form a non-decreasing sequence (staying flat between two days is fine). Given the full log of every bank's five reports, find every bank that earns the Steady Rebound award.
bank_id day charge. day is between 1 and 5, and charge is the bank's charge percentage on that day. It is guaranteed that every distinct bank_id appearing in the log has exactly 5 rows, one for each day from 1 to 5.Print the bank_id values of every bank that earns the Steady Rebound award, sorted in ascending order, space-separated on one line. If no bank qualifies, print an empty line.
Example 1
Input
10 10 1 20 10 3 45 10 2 20 10 5 90 10 4 45 20 1 50 20 2 40 20 3 60 20 4 70 20 5 80
Expected
10
Explanation
Bank 10's five readings, ordered by day, are 20, 20, 45, 45, 90 — never decreasing, so it earns the award. Bank 20's readings are 50, 40, 60, 70, 80; the drop from 50 (day 1) to 40 (day 2) disqualifies it. Only bank 10 is printed.
Example 2
Input
5 7 1 80 7 2 80 7 3 80 7 4 80 7 5 79
Expected
(empty)Explanation
Bank 7's five readings are 80, 80, 80, 80, 79. The drop on the final day (80 to 79) breaks the non-decreasing pattern, so bank 7 does not qualify. Since no bank qualifies at all, the output is an empty line.
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 →