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的更多相关文章
随机推荐
- hdu 4749
题目很简单,不过题意很难看懂. 就是给一个标准的大小关系的队列,从原队列中找出最多的匹配子队列,感觉就像一个KMP算法+贪心: 不过这个题可能数据有点水把,竟然只要判断相邻的关系就可以A掉: 代码: ...
- js 模块化
http://kb.cnblogs.com/page/132461/ http://www.adequatelygood.com/JavaScript-Module-Pattern-In-Depth. ...
- Django 安全策略的 7 条总结!
Florian Apolloner 发言主题为 Django 安全,其中并未讨论针对 SSL 协议的攻击--因为那不在 Django 涉及范围内.(如感兴趣可参考 https://www.ssllab ...
- MySQL 对于大表(千万级),要怎么优化呢?
http://www.zhihu.com/question/19719997 提问:如何设计或优化千万级别的大表?此外无其他信息,个人觉得这个话题有点范,就只好简单说下该如何做,对于一个存储设计,必须 ...
- [收藏转贴]WCFRESTFul服务搭建及实现增删改查
RESTful Wcf是一种基于Http协议的服务架构风格, RESTful 的服务通常是架构层面上的考虑. 因为它天生就具有很好的跨平台跨语言的集成能力,几乎所有的语言和网络平台都支持 HTTP ...
- C#连接数据库的一些鲜为人知的方法
用过VS2008和VS2010的开发人员肯定知道在安装这个IDE的时候会自动安装了一个精简版的SQL数据库服务SqlExpress,这个数据库系统少了最重要的企业管理器,也就是说不能用它来建数据表和一 ...
- 【转】Android4.4(MT8685)源码蓝牙解析--BLE搜索
原文网址:http://blog.csdn.net/u013467735/article/details/41962075 BLE:全称为Bluetooth Low Energy.蓝牙规范4.0最重要 ...
- 30个最常用css选择器解析
转自:http://www.cnblogs.com/yiyuanke/archive/2011/10/22/CSS.html 你也许已经掌握了id.class.后台选择器这些基本的css选择器.但这远 ...
- List 三种遍历的方法
学习java语言list遍历的三种方法,顺便测试各种遍历方法的性能,测试方法为在ArrayList中插入1千万条记录,然后遍历ArrayList,发现了一个奇怪的现象,测试代码如下: package ...
- Bootstrap+MetroNic_1.5.4 Head meta
Bootstrap+MetroNic_1.5.4 HTML <meta> 标签设定含义: <meta http-equiv="X-UA-Compatible" c ...
