Олимпиадный тренинг

Задача 39482. Subsequence of length L


Given a sequence of N numbers. All its continuous subsequences are considered, in which the number of negative numbers does not exceed C. Find among them a subsequence with the maximum sum, length L. In your answer, indicate the sum of the found subsequence.

Input
The first line contains 3 numbers: the number of numbers N (1 <= N <= 1 000 000),  L and C< /code> (\(1 <= L, C <= N <= 1,000,000\)). Each of the following N lines contain one number, modulo not exceeding 1000.

An example of the organization of source data in the input file (for L = 3 and C = 3):
5 3 3
1
-1
2
-2
3


Several sequences can be selected in this set, but with a maximum sum of 3 it will be: 2+(-2)+3. 
Answer(for С = 3 and L = 3): 3.  ;