Steven and Felix wrote and then sell "Competitive Programming 2" (CP2) book via lulu.com.
Every day, lulu reports the number of book sales (usually not 0 :D) to Steven, the main author.
(btw, today, Steven records an additional 8 (eight) books sold locally to CS3233 students :D).
Over N days (0 < N <= 2555, or 7 years), Steven enters this sales data into a list L.
Thus, list L contains N non-negative integers, each of them less than or equal to 50 (the record sale in one single day via lulu.com is 26 books).
Now, Steven wants to analyze this data.
He wants to know the minimal length of the sublist Lsub of consecutive elements of list L,
such that the sum of Lsub is greater than or equal to a positive integer S (0 < S < 10000).
(fyi, he wants to compute this because he said that the days in Lsub are his "happy days" because many people buy his book beyond his target level S).
Many test cases will be given.
For each test case the program has to read the numbers N and S, separated by a space, from the first line.
The N integers of list L are given in the second line of the test case, separated by a space.
The input will finish with the end of file (EOF) signal.
For each test case, print the result on separate line.
If there is no such Lsub, simply print 0 in a line by itself.
10 15 5 1 3 5 10 7 4 9 2 8 5 11 1 2 3 4 5 5 16 1 2 3 4 5
2 3 0
For the first test case, Lsub = [10 7] of length 2 in L = 5 1 3 5 [10 7] 4 9 2 8 has sum >= 15, output 2.
For the second test case, Lsub = [3 4 5] of length 3 in L = 1 2 [3 4 5] has sum >= 11, output 3.
There is no answer in the third test case.
Subtask | Score |
---|---|
1 | 100 |