#t85. 最短旅行时间

最短旅行时间

Minimum Travel Time

Problem Description

There are nn cities, numbered 1,2,…,n1, 2, \dots, n. Between city ii and city i+1i+1 there is a bidirectional road, and traversing it takes time aia_i.

You start from city 11 and want to reach city nn. Apart from the roads, you also have a teleporter with a range of kk: once used, it takes you directly from city ii to city i−ki-k or city i+ki+k; if the target index is less than 11 it is treated as 11, and if greater than nn it is treated as nn. The teleporter can be used at most once, and using it consumes no time.

You do not need to visit every city. Find the minimum time needed to travel from city 11 to city nn.

Input Format

Two lines. The first line contains two positive integers n,kn, k (1≤n≤1061 \le n \le 10^6, 0≤k<n0 \le k < n).

The second line contains n−1n-1 integers; the ii-th number is aia_i (ai≤108a_i \le 10^8).

Output Format

Output a single integer: the minimum travel time.

Sample Input 1

4 0
1 2 3

Sample Output 1

6

Sample Input 2

4 1
1 2 3

Sample Output 2

3