#P8049. [COCI 2010/2011 #5] DVONIZ(加强版)
[COCI 2010/2011 #5] DVONIZ(加强版)
Background
The statement is the same as the original problem P7635 [COCI2010-2011#5] DVONIZ, except that the Constraints, time and memory limits, and score are different.
Problem Description
We call a sequence of elements interesting if the sum of the first elements or the sum of the last elements is not greater than .
Given a sequence of length , for each position, output the length of the longest interesting subarray starting from that position.
Input Format
The first line contains integers and .
Each of the next lines contains one integer from the sequence . All these integers are positive, and their sum does not exceed .
Output Format
Output lines in total. The -th line contains an integer representing the length of the longest interesting subarray starting from the -th element.
If there is no interesting subarray starting at this position, output 0.
5 10000
1
1
1
1
1
4
4
2
2
0
5 9
1
1
10
1
9
2
0
0
2
0
8 3
1
1
1
1
1
1
1
1
6
6
6
4
4
2
2
0
Hint
Sample Explanation #1
For the first position in Sample , there are subarrays, and all of them satisfy the condition, so we take the longest one with length .
Constraints
For of the testdata, .
For of the testdata, .
For of the testdata, .
For of the testdata, , , .
Translated by ChatGPT 5