HDU2088JAVA
Box of BricksTime Problem Description
Little Bob likes playing with his box of bricks. He
puts the bricks one upon another and builds stacks of different height. “Look, I've built a wall!”, he tells his older sister Alice. “Nah, you should make all stacks the same height. Then you would have a real wall.”, she retorts. After a little consideration, Bob sees that she is right. So he sets out to rearrange the bricks, one by one, such that all stacks are the same height afterwards. But since Bob is lazy he wants to do this with the minimum number of bricks moved. Can you help? ![]() Input
The input consists of several data sets. Each set
begins with a line containing the number n of stacks Bob has built. The next line contains n numbers, the heights hi of the n stacks. You may assume 1≤n≤50 and 1≤hi≤100. The total number of bricks will be divisible by the number The input is terminated by a set starting Output
For each set, print the minimum number of bricks that
have to be moved in order to make all the stacks the same height. Output a blank line between each set. Sample Input
6
5 2 4 1 7 5 0 Sample Output
5
|
HDU2088JAVA的更多相关文章
随机推荐
- IEEE二进制浮点数算术标准(IEEE 754)
整理自IEEE 754 IEEE二进制浮点数算术标准(IEEE 754)是20世纪80年代以来最广泛使用的浮点数运算标准,为许多CPU与浮点运算器所采用.这个标准定义了表示浮点数的格式(包括负零-0) ...
- 李洪强漫谈iOS开发[C语言-030]-逻辑运算符
- QT事件研究的文章
我始终认为,Windows里最重要的不是API,而是消息.同理,QT里最重要的是事件.然而我对事件的原理和用法至今不是很理解,先放几篇文章在这里,有空回来细细研读: http://m.blog.chi ...
- 解决crystal report水晶报表在浏览器提示bobj未定义的错误
网上的中文文章(比如这篇文章)都是写的部署到服务器后出现的问题,同时也指出要把crystal report的aspnet_client文件夹拷贝到对应项目的根目录里,这样就可以正常显示了,但是具体到我 ...
- 使用@ResponseBody 出现错误Could not find acceptable representation
org.springframework.web.HttpMediaTypeNotAcceptableException: Could not find acceptable representatio ...
- bzoj3530
比较恶心的题目不难发现是在自动机上做数位dp注意要考虑前导0,题目中给出的233是幸运数,20233不是为此我非常猥琐的写了一个四维dp,用记忆化搜索实现 ; ..,..,..,..] of long ...
- \u202e
document.write('\u202e1\u202e2\u202e3')
- xPath Helper
整个抓取使用了 xpath.正则表达式.消息中间件.多线程调度框架(参考).xpath 是一种结构化网页元素选择器,支持列表和单节点数据获取,他的好处可以支持规整网页数据抓取.我们使用的是google ...
- 比较详细的利用虚拟机对SD卡FAT32+EXT4+Ext4分区图解教程
如果大家嫌虚拟机复杂,我这里提供一个我没用虚拟机之前的分区方法:这个方法实际是可行的 我在没有用虚拟机之前,我是这样操作的1.首先在分区软件分好fat32+ext2+ext22.然后用recovery ...
- 基于MyEclipse+9.0+++Tomcat+7.0的SSH+平台搭建
基于MyEclipse+9.0+++Tomcat+7.0的SSH+平台搭建 http://wenku.baidu.com/view/96fbfe0f581b6bd97f19ea1d.html 用MyE ...
