#P7594. 「EZEC-8」Clean Up
「EZEC-8」Clean Up
Description
There is an interval of width . At position , there are blocks stacked up like Tetris.
You may choose any position and spend energy to remove at most blocks at that position. At the same time, at a position whose distance from the chosen position is , you can remove at most blocks, where the distance between two adjacent positions is . Note that must be a positive integer.
Find the minimum amount of energy needed to clear all blocks in the entire interval.
Input Format
The input has two lines.
The first line contains an integer .
The second line contains integers, where the -th number is .
Output Format
Output one line with one number, indicating the minimum required energy.
5
1 4 3 4 1
5
8
1 2 1 0 0 1 2 1
4
Hint
Sample Explanation
For the first sample, one optimal plan is to choose position and spend energy.
For the second sample, one optimal plan is to choose position and spend energy, then choose position and spend energy.
This problem uses bundled testdata.
- Subtask 1 (5 points): .
- Subtask 2 (20 points): , .
- Subtask 3 (20 points): .
- Subtask 4 (20 points): .
- Subtask 5 (35 points): No special constraints.
For of the testdata, , .
Translated by ChatGPT 5
京公网安备 11011102002149号