#P5638. 【CSGRound2】光骓者的荣耀

【CSGRound2】光骓者的荣耀

Description

The land that Little K has conquered contains a total of nn cities. City ii and city i+1i+1 are connected by a two-way highway, and traveling along this road takes time aia_i.

In order to care about the people’s lives, Little K decides to make regular visits. Each time, he will travel from city 11 to city nn and visit the cities he passes through. The destination must be city nn.

Moreover, he has a teleporter with teleport radius kk, meaning he can teleport to iki-k and i+ki+k. If the target city index is less than 11, it becomes 11; if it is greater than nn, it becomes nn.

However, his teleporter does not have enough power and can only be used once. Also, for some reason, he wants to finish the visits as quickly as possible, so he asks you, the Minister of Transportation, what the minimum time is.

Note: He does not need to visit all cities, and using the teleporter costs no time.

Input Format

Two lines. The first line contains two positive integers n,kn, k.

The second line contains n1n-1 integers, where the ii-th one denotes aia_i.

Output Format

One integer, indicating the answer.

4 0
1 2 3
6
4 1
1 2 3
3

Hint

Sample Explanation 1:

The illustrations for samples 1 and 2 are both the following image:

If the teleporter is not used and you just walk directly, the answer is 66. It can be proven that this is the minimum.

Sample Explanation 2:

Use it at 33 and teleport to 44. The answer is 33. It can be proven that this is the minimum.

Constraints:

For all testdata, n2n \ge 2, k1k \ge 1, ai>0a_i > 0.

Test Point ID Range of nn Range of kk Range of aia_i
1101 \sim 10 100\le 100 105\le 10^5
112011 \sim 20 3×103\le 3 \times 10^3 109\le 10^9
2121 105\le 10^5 1012\le 10^{12}
2222 2×105\le 2 \times 10^5
2323 5×105\le 5 \times 10^5
242524 \sim 25 106\le 10^6

Translated by ChatGPT 5