#Q182. 「一本通 5.5 练习 1」烽火传递
「一本通 5.5 练习 1」烽火传递
Description
Original source: NOIP 2010 Senior Division Preliminary Round · Problem Completion
Beacon towers are crucial military defense installations, typically built along major transportation routes or strategic locations. In case of military activity, smoke signals are used during the day and fire signals at night to relay information.
Between two cities, there are beacon towers, each with a certain cost to send a signal. To ensure accurate transmission of intelligence, at least one out of every consecutive beacon towers must send a signal. Given , , and the cost of each beacon tower, compute the minimum total cost required to accurately transmit information between the two cities.
Input Format
The first line contains and , representing the number of beacon towers and the consecutive tower count .
The second line contains integers, each denoting the cost of the corresponding beacon tower.
Output Format
Output a single integer, the minimum cost.
Sample 1
Send signals from the 2nd and 5th beacon towers.
5 3
1 2 5 6 2
4
Data Range and Hint
For all data, , and .