A9217 | Levko and Array
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
Levko has an array that consists of integers: $a_{1},a_{2},...\ ,a_{n}$ . But he doesn’t like this array at all.
Levko thinks that the beauty of the array $a$ directly depends on value $c(a)$ , which can be calculated by the formula:
 The less value $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 $k$ 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)$ he can reach.
Levko thinks that the beauty of the array $a$ directly depends on value $c(a)$ , which can be calculated by the formula:
 The less value $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 $k$ 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)$ he can reach.
输入格式
The first line contains two integers $n$ and $k$ ( $1<=k<=n<=2000$ ). The second line contains space-separated integers $a_{1},a_{2},...\ ,a_{n}$ ( $-10^{9}<=a_{i}<=10^{9}$ ).
输出格式
A single number — the minimum value of $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: $4$ , $4$ , $4$ , $4$ , $4$ .
In the third sample he can get array: $1$ , $2$ , $3$ , $4$ , $5$ , $6$ .
In the third sample he can get array: $1$ , $2$ , $3$ , $4$ , $5$ , $6$ .
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted