当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

5191:Building Blocks

题目描述
After enjoying the movie,LeLe went home alone. LeLe decided to build blocks.
LeLe has already built $n$ piles. He wants to move some blocks to make $W$ consecutive piles with exactly the same height $H$.

LeLe already put all of his blocks in these piles, which means he can not add any blocks into them. Besides, he can move a block from one pile to another or a new one,but not the position betweens two piles already exists.For instance,after one move,"3 2 3" can become "2 2 4" or "3 2 2 1",but not "3 1 1 3".

You are request to calculate the minimum blocks should LeLe move.
输入解释
There are multiple test cases, about $100$ cases.

The first line of input contains three integers $n,W,H(1 \leq n,W,H \leq 50000)$.$n$ indicate $n$ piles blocks.

For the next line ,there are $n$ integers $A_1,A_2,A_3,……,A_n$ indicate the height of each piles. $(1 \leq A_i \leq 50000)$

The height of a block is 1.
输出解释
Output the minimum number of blocks should LeLe move.

If there is no solution, output "-1" (without quotes).
输入样例
4 3 2
1 2 3 5
4 4 4
1 2 3 4
输出样例
1
-1

提示
In first case, LeLe move one block from third pile to first pile.
来自杭电HDUOJ的附加信息
Recommend hujie

该题目是Virtual Judge题目,来自 杭电HDUOJ

题目来源 BestCoder Round #34

源链接: HDU-5191

最后修改于 2020-10-25T23:20:34+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
2000/1000MS(Java/Others) 65536/65536K(Java/Others)