Busiest Five Minutes
A web server's access log has been boiled down to one number per second: how many requests
arrived during that second. The infrastructure team is capacity planning and wants to know the
worst k-second window — the stretch of k consecutive seconds that received the most requests
in total, since that's the load their servers need to be provisioned for.
You are given the per-second request counts for n consecutive seconds, numbered 1 to n in
the order they occurred. Find a window of exactly k consecutive seconds (seconds s, s+1, ..., s+k-1 for some valid starting second s) whose total request count is as large as possible. If
several windows tie for the largest total, report the one with the smallest starting second s.
Input
The first line contains two integers n and k (1 ≤ k ≤ n ≤ 10^6).
The second line contains n integers c_1, c_2, ..., c_n (0 ≤ c_i ≤ 10^5), where c_i is the
number of requests received during second i.
Output
Print two integers: the total number of requests in the busiest k-second window, and the
starting second s (1 ≤ s ≤ n - k + 1) of the earliest window achieving that total.
Notes
The total can exceed what fits in a 32-bit integer, so accumulate it with a 64-bit (or wider) type.