G.W. Coding Contest 3 Tiebreaker: Largest Range

Given an positive \(\{\text{0} \leq x \lt 2^{31} \}\) integer array of length \(N\), return the largest possible range \(l\) to \(r\) inclusive in which the sum from \(l\) to \(r\) does not exceed \(K\)


Input Specification:

The first line contains the integer \(N\), the length of the array, and \(K\), the value which the sum must not exceed, seperated by a space.

The second line contains each element of the array seperated by space.

\(\{\text{1 } \leq N, K, l, r \leq 10^6 \}\)


Output Specification:

Output \(l\) and \(r\) seperated by a space

If there are multiple correct answers, the output should be the one which appears first. It is guaranteed there will be a correct answer.


TIME CONSTRAINT: 1s

Sample Input 1:

5 6
1 2 3 4 5

Sample Output 1:

0 2


Sample Input 2:

7 5
2 1 1 1 1 1 3

Sample Output 2:

1 5

Submit Solution

Problem author: Vincent