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

#PS0000104. Hàng rào (Fence)

HỌC THEO LỘ TRÌNH

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

1 lộ trình

Hàng rào (Fence)

Fence

Source: Codeforces

Version: Phuoc Hung OJ Extended

Problem Statement

Polycarpus has a fence in front of his house consisting of nn equal-width planks in a row. Plank ii has height hih_i metres. To move a piano inside, he must remove exactly kk consecutive planks. Since taller planks are harder to remove, he wants the minimum possible total height of the chosen planks. The fence is not circular. Find a starting position attaining that minimum.

Fence

Input

The first line contains integers n,kn,k.

The second line contains nn integers h1,…,hnh_1,\ldots,h_n, the heights from left to right.

Output

Print one integer jj (1≤j≤n−k+11\le j\le n-k+1) minimizing hj+⋯+hj+k−1h_j+\cdots+h_{j+k-1}. If several positions attain the minimum, any of them is accepted.

Subtasks

  • Subtask 1 (20 points): 1≤n≤1500001\le n\le 150000; k=1k=1; 1≤hi≤1001\le h_i\le 100 for all 1≤i≤n1\le i\le n.
  • Subtask 2 (30 points): 1≤n≤10001\le n\le 1000; 1≤k≤n1\le k\le n; 1≤hi≤1001\le h_i\le 100 for all 1≤i≤n1\le i\le n.
  • Subtask 3 (50 points): 1≤n≤1500001\le n\le 150000; 1≤k≤n1\le k\le n; 1≤hi≤1001\le h_i\le 100 for all 1≤i≤n1\le i\le n.

Examples

Input

7 3
1 2 6 1 1 7 1

Output

3

Explanation

Exactly three consecutive planks must be removed. The totals for starts 1, 2, 3, 4, 5 are 9,9,8,9,99,9,8,9,9. Starting at 3 removes heights 6,1,16,1,1 metres, attaining the minimum 8.