PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#PS0000204. Tổng đoạn lớn nhất dài ít nhất L (Maximum Subarray Sum with Minimum Length)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

Tổng đoạn lớn nhất dài ít nhất L (Maximum Subarray Sum with Minimum Length)

Maximum Subarray Sum with Minimum Length

Source: Phước Hưng OJ

Version: Phuoc Hung OJ Extended

Problem Statement

Given nn integers aia_i and an integer LL, find the maximum sum of a consecutive interval of length at least LL. Negative elements are allowed; the interval must be nonempty.

Input

The first line contains n,Ln,L. The second line contains exactly nn integers aia_i.

Output

Print the maximum sum.

Subtasks

  • Subtask 1 (30 points): 1≤n≤2001\le n\le 200; ∣ai∣≤109|a_i|\le10^9; 1≤L≤n1\le L\le n.
  • Subtask 2 (30 points): 1≤n≤2000001\le n\le 200000; ∣ai∣≤109|a_i|\le10^9; 1≤L≤n1\le L\le n; L=nL=n.
  • Subtask 3 (40 points): 1≤n≤2000001\le n\le 200000; ∣ai∣≤109|a_i|\le10^9; 1≤L≤n1\le L\le n.

Example 1

Input

4 2
2 -3 5 -1

Output

4

Explanation

Intervals [3,4] and [1,3] both sum to 4. No other qualifying interval has a larger sum.

Example 2

Input

3 2
-5 -2 -3

Output

-5

Explanation

Interval [2,3] sums to -5; the other qualifying sums are -7 and -10.