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的更多相关文章
随机推荐
- bzoj 2706: [SDOI2012]棋盘覆盖 Dancing Link
2706: [SDOI2012]棋盘覆盖 Time Limit: 10 Sec Memory Limit: 256 MBSubmit: 255 Solved: 77[Submit][Status] ...
- Unity3d 协程的注意问题(新手须注意,老手须加勉)
关于unity3d的协程,非常的好用,比如等待几秒执行,等待下一帧执行等! 但是也有潜在的问题: 1.协程是单线程的,在主线程中完成 2.如果发现yield, 那么这一帧会结束,那么等下一帧调用此脚本 ...
- 不同框架实现的WebService的服务端获取HttpServletRequest的方法
一. 基于xfire实现的WebService HttpServletRequest request = XFireServletController.getRequest(); 二. 基于axis实 ...
- 李洪强iOS开发-网络新闻获取数据思路回顾
李洪强iOS开发-网络新闻获取数据思路回顾 01 创建一个继承自AFHTTPSessionManager的工具类:LHQNetworkTool 用来发送网络请求获取数据 1.1 定义类方法返回单例对 ...
- [转贴]Linq之动态查询
最近写Linq碰到一个问题, 就是如果要写一个查询系统,这个系统里面有很多TextBox可以填, 然后捞出符合各个字段的数据. 在SQL查询的时候还满方便的,用字符串连连连就可以了, ( 也就是sql ...
- Service知识点总结
转载请注明出处:http://blog.csdn.net/krislight/article Service可以看作一个后台服务,但并非是开启另外的线程,Service还是在主线程中运行.所以需避免耗 ...
- google python/c++ code style naming
python: Guidelines derived from Guido's Recommendations Type Public Internal Packages lower_with_und ...
- Properties vs. Attributes
http://blogs.msdn.com/b/ericlippert/archive/2009/02/02/properties-vs-attributes.aspx Here is yet ano ...
- bzoj1295
考虑到这道题n,m都很小,我们考虑先穷举起点i 下面我们要做的是找出移走k个障碍后,点i所能到的最大距离 我们可以把这个问题转化为判定性问题 对于一对点i,j,如果他们之间存在一条路径,障碍数(包括起 ...
- [ZOJ 3622] Magic Number
Magic Number Time Limit: 2 Seconds Memory Limit: 32768 KB A positive number y is called magic n ...