Codeforces Round 500 (Div. 2) [based on EJOI]
E
Hills
Codeforces
未评级
原题
← DF →
翻译中…

Welcome to Innopolis city. Throughout the whole year, Innopolis citizens suffer from everlasting city construction.

翻译中…

From the window in your room, you see the sequence of $*n*$ hills, where $*i*$-th of them has height $*a*_{*i*}$. The Innopolis administration wants to build some houses on the hills. However, for the sake of city appearance, a house can be only built on the hill, which is strictly higher than neighbouring hills (if they are present). For example, if the sequence of heights is $5, 4, 6, 2$, then houses could be built on hills with heights $5$ and $6$ only.

翻译中…

The Innopolis administration has an excavator, that can decrease the height of an arbitrary hill by one in one hour. The excavator can only work on one hill at a time. It is allowed to decrease hills up to zero height, or even to negative values. Increasing height of any hill is impossible. The city administration wants to build $*k*$ houses, so there must be at least $*k*$ hills that satisfy the condition above. What is the minimum time required to adjust the hills to achieve the administration's plan?

翻译中…

However, the exact value of $*k*$ is not yet determined, so could you please calculate answers for all $*k*$ in range image? Here image denotes $*n*$ divided by two, rounded up.

翻译中…

Input

翻译中…

The first line of input contains the only integer $*n*$ ($1 ≤ *n* ≤ 5000$)—the number of the hills in the sequence.

翻译中…

Second line contains $*n*$ integers $*a*_{*i*}$ ($1 ≤ *a*_{*i*} ≤ 100 000$)—the heights of the hills in the sequence.

翻译中…

Output

翻译中…

Print exactly image numbers separated by spaces. The $*i*$-th printed number should be equal to the minimum number of hours required to level hills so it becomes possible to build $*i*$ houses.

翻译中…

Note

翻译中…

In the first example, to get at least one hill suitable for construction, one can decrease the second hill by one in one hour, then the sequence of heights becomes $1, 0, 1, 1, 1$ and the first hill becomes suitable for construction.

翻译中…

In the first example, to get at least two or at least three suitable hills, one can decrease the second and the fourth hills, then the sequence of heights becomes $1, 0, 1, 0, 1$, and hills $1, 3, 5$ become suitable for construction.

翻译中…

样例

Input #1
5
1 1 1 1 1
Output #1
1 2 2
InputCopy OutputCopy
Input #2
3
1 2 3
Output #2
0 2
InputCopy OutputCopy
Input #3
5
1 2 3 2 2
Output #3
0 1 3
InputCopy OutputCopy
题目信息
题号
1013E
时间限制
1 s
内存限制
512 MB

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。