Loading...
Loading...
Loading...
A call centre counts the calls in each of n hours. Find the stretch of k hours in a row with the fewest calls. Print its total and the 0-based hour where it starts. If two stretches tie, print the earlier one.
Example
Input
6 3 9 4 6 2 8 1
Output
11 3
The stretch totals are 19, 12, 16 and 11. The smallest is 11, starting at hour 3.
Try the problem first. Open one hint at a time.
Use < and not <= when you compare totals, so ties keep the earlier start.
A stretch that ends at right starts at right - k + 1.
Write your Python code, run it on the examples and submit it to hidden tests.
Solve in the editor