CF360B.Levko and Array

普及/提高-

通过率:0%

AC君温馨提醒

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

题目描述

Levko has an array that consists of integers: a1,a2,... ,ana_{1},a_{2},...\ ,a_{n} . But he doesn’t like this array at all.

Levko thinks that the beauty of the array aa directly depends on value c(a)c(a) , which can be calculated by the formula:

The less value c(a)c(a) is, the more beautiful the array is.It’s time to change the world and Levko is going to change his array for the better. To be exact, Levko wants to change the values of at most kk array elements (it is allowed to replace the values by any integers). Of course, the changes should make the array as beautiful as possible.

Help Levko and calculate what minimum number c(a)c(a) he can reach.

输入格式

The first line contains two integers nn and kk ( 1<=k<=n<=20001<=k<=n<=2000 ). The second line contains space-separated integers a1,a2,... ,ana_{1},a_{2},...\ ,a_{n} ( 109<=ai<=109-10^{9}<=a_{i}<=10^{9} ).

输出格式

A single number — the minimum value of c(a)c(a) Levko can get.

输入输出样例

  • 输入#1

    5 2
    4 7 4 7 4
    

    输出#1

    0
    
  • 输入#2

    3 1
    -100 0 100
    

    输出#2

    100
    
  • 输入#3

    6 3
    1 2 3 7 8 9
    

    输出#3

    1
    

说明/提示

In the first sample Levko can change the second and fourth elements and get array: 44 , 44 , 44 , 44 , 44 .

In the third sample he can get array: 11 , 22 , 33 , 44 , 55 , 66 .

首页