#P16075. [ICPC 2023 NAC] Frequent Flier

[ICPC 2023 NAC] Frequent Flier

题目描述

An airline is offering a strange new rewards program to offer free flights to travelers.

The program can be parameterized with two integers mm and kk. Within any mm consecutive months, a traveler must pay for at least kk of those flights (if there are fewer than kk flights in that interval, all of those flights must be paid for). Other flights within that interval are free. Note that this condition needs to be true for all mm-month intervals, including all of the ones that start before your first flight.

You have a schedule of the number of flights you’ll take over the next many months. You want to know the minimum number of flights you’ll need to pay for.

输入格式

The first line of input contains three integers nn, mm (1n,m2×1051 \leq n, m \leq 2 \times 10^5) and kk (1k1091 \leq k \leq 10^9), where nn is the number of consecutive months ahead that you have flights planned, and mm and kk are the parameters of the airline’s rewards program.

Each of the next nn lines contains an integer ff (1f1091 \leq f \leq 10^9), which is the number of flights you plan to take during that month.

输出格式

Output a single integer, which is the minimum number of planned flights that you must pay for.

8 3 2
3
1
4
1
5
9
2
6
8