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的更多相关文章
随机推荐
- HTML5 Geolocation
http://diveintohtml5.info/geolocation.html http://msdn.microsoft.com/en-us/library/windows/apps/hh44 ...
- 如何有效申请TI的免费样片
转自如何有效申请TI的免费样片 TI公司愿意为支持中国大学的师生们的教学.实验.创新实践.竞赛和科研项目,提供有限数量的免费样片.首先需要指出的是:所有的样片申请应该是诚实正当的,所有不恰当的申 ...
- Java 构造器 一道构造器调用子类重载方法的题目
构造器中不能new本类对象,否则进入死循环. 构造器没有返回值,也没有void修饰. 使用关键字super可以调用父类的构造器,而且这一句必须放在第一句的位置,否则无法编译. 题目: 请写出以下程序的 ...
- org.springframework.web.bind.ServletRequestDataBinde
org.springframework.validation Class DataBinder java.lang.Object org.springframework.validation.Data ...
- struts2文件异步上传
代码结构 用到的js文件: 用到的jar包: jar和js库文件下载地址:下载地址 首先我们写FileAction类 package com.ajaxfile.action; import java. ...
- 【HDOJ】2707 Steganography
简单字符串,读懂题,很容易AC. #include <stdio.h> #include <string.h> ], line[], des[]; int main() { i ...
- 使用Eclipse创建模板并格式化代码
eclipse设置方式: window-preferences-->java-code Style-formatter 在编写完代码后使用代码格式化程序对代码进行格式化,有利于版本冲突时进行对比 ...
- (转载)设计模式学习笔记(十一)——Facade外观模式
(转载)http://www.cnblogs.com/kid-li/archive/2006/07/10/446904.html Facade外观模式,是一种结构型模式,它主要解决的问题是:组件的客户 ...
- Toad 中的compare使用方法
1.首先连接要对比后执行的数据库 2.设置对比内容 3.对比后的执行脚本
- JavaScript高级程序设计56.pdf
选择选项 对于只允许选择一项的选择框,访问选中项最简单的方式是selectedIndex属性 var selectedOption=selectbox.options["selectbox. ...
