CF1012C.Hills

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

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 nn hills, where ii -th of them has height aia_{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,25,4,6,2 , then houses could be built on hills with heights 55 and 66 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 kk houses, so there must be at least kk 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 kk is not yet determined, so could you please calculate answers for all kk in range ? Here denotes nn divided by two, rounded up.

输入格式

The first line of input contains the only integer nn ( 1<=n<=50001<=n<=5000 )—the number of the hills in the sequence.

Second line contains nn integers aia_{i} ( 1<=ai<=1000001<=a_{i}<=100000 )—the heights of the hills in the sequence.

输出格式

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

输入输出样例

  • 输入#1

    5
    1 1 1 1 1
    

    输出#1

    1 2 2 
    
  • 输入#2

    3
    1 2 3
    

    输出#2

    0 2 
    
  • 输入#3

    5
    1 2 3 2 2
    

    输出#3

    0 1 3 
    

说明/提示

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,11,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,11,0,1,0,1 , and hills 1,3,51,3,5 become suitable for construction.

首页