#C13809. Shortest Subarray with Sum At Least Target

    ID: 43388 Type: Default 1000ms 256MiB

Shortest Subarray with Sum At Least Target

Shortest Subarray with Sum At Least Target

Given an array of integers a=[a1,a2,,an]a = [a_1,a_2,\dots,a_n] and a target integer TT, find the shortest contiguous subarray such that (\sum_{i=l}^{r}a_i \ge T). If there are multiple solutions with the same length, output the one found first. If no such subarray exists, output -1.

Input is read from standard input and output is written to standard output.

inputFormat

The first line contains two integers: (n) and (T) (the number of elements in the array and the target sum).

The second line contains (n) integers representing the array elements, separated by spaces.

outputFormat

If a valid subarray exists, print its elements separated by a single space in one line. Otherwise, output -1.## sample

3 10
1 2 3
-1