#P1614. 爱与愁的心痛

爱与愁的心痛

Description

Recently there are nn unpleasant events, and each one has a positive integer sting value (his tolerance is extremely low). The guru "Ai Yu Chou" wants to know the minimum sum of mm consecutive sting values. Because he is busy, he asks you to write a program to tell him.

Input Format

The first line contains two space-separated integers, nn and mm.

Lines 22 to n+1n + 1 each contain one integer. For i=1,2,,ni = 1, 2, \ldots, n, line i+1i + 1 contains an integer aia_i, the sting value of the ii-th event.

Output Format

Output one line with a single integer: the minimum sum of any mm consecutive sting values.

8 3
1
4
7
3
1
2
4
3
6

Hint

Constraints

  • For 30%30\% of the testdata, it is guaranteed that n20n \leq 20.
  • For 60%60\% of the testdata, it is guaranteed that n100n \leq 100.
  • For 90%90\% of the testdata, it is guaranteed that n103n \leq 10^3.
  • For 100%100\% of the testdata, it is guaranteed that 0mn3×1030 \leq m \leq n \leq 3 \times 10^3, 1ai1001 \leq a_i \leq 100.

Translated by ChatGPT 5