Sequence - MarisaOJ: Marisa Online Judge

Sequence

Time limit: 1000 ms
Memory limit: 256 MB
Given a sequence of $n$ integers $a_1,a_2,...,a_n$ and two positive integers $1 \le L \le R \le n.$ Find a subsequence of consecutive elements with length $s$ $(L \le s \le R)$ which has the largest sum of elements. ### Input - The first line contains three integers $n,L,R$ $(1 \le n \le 10^5)$ - The second line contains $n$ integers $a_1,a_2,...,a_n (|a_i| \le 10^9)$ ### Output Contains a line containing a number that is the sum of the largest elements of the subsequence found. Input: ``` 5 2 3 1 3 -1 5 -1 ``` Output: ``` 7 ``` ### Subtask - Subtask 1 ($30 \\%$): $n \le 100$ - Subtask 2 ($30 \\%$): $n \le 5000$ - Subtask 3 ($40 \\%$): No additional constraints