POJ 1477:Box of Bricks
Time Limit: 1000MS | Memory Limit: 10000K | |
Total Submissions: 19949 | Accepted: 8029 |
Description
real wall.", she retorts. After a little con- sideration, 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 total number of bricks will be divisible by the number of stacks. Thus, it is always possible to rearrange the bricks such that all stacks have the same height.
The input is terminated by a set starting with n = 0. This set should not be processed.
Output
Output a blank line after each set.
Sample Input
6
5 2 4 1 7 5
0
Sample Output
Set #1
The minimum number of moves is 5.
Source
Southwestern European Regional Contest 1997
你 离 开 了 , 我 的 世 界 里 只 剩 下 雨 。 。 。
#include <stdio.h>
int main()
{
int n,i,s,aver,a[51],num,j=0;
while(~scanf("%d", &n))
{
if(n == 0) break;
j++,s = 0,num = 0;
for(i = 0; i < n; i++)
{
scanf("%d", &a[i]);
s+=a[i];
}
aver= s/n;
for(i = 0; i < n; i++)
if(a[i] > aver)
num = num + a[i] - aver;
printf("Set #%d\nThe minimum number of moves is %d.\n\n", j, num);
}
return 0;
}
POJ 1477:Box of Bricks的更多相关文章
- HDOJ 1326. Box of Bricks 纯水题
Box of Bricks Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) To ...
- Box of Bricks最小移动砖块数目
Description Little Bob likes playing with his box of bricks. He puts the bricks one upon another and ...
- [POJ1477]Box of Bricks
Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 19503 Accepted: 7871 Description Litt ...
- HDOJ(HDU) 2088 Box of Bricks(平均值)
Problem Description Little Bob likes playing with his box of bricks. He puts the bricks one upon ano ...
- HDOJ 1326 Box of Bricks(简单题)
Problem Description Little Bob likes playing with his box of bricks. He puts the bricks one upon ano ...
- 591 - Box of Bricks
Box of Bricks Little Bob likes playing with his box of bricks. He puts the bricks one upon another ...
- Box of Bricks
Box of Bricks Time Limit : 2000/1000ms (Java/Other) Memory Limit : 65536/32768K (Java/Other) Total ...
- HDU 2088 Box of Bricks
http://acm.hdu.edu.cn/showproblem.php?pid=2088 Problem Description Little Bob likes playing with his ...
- HDU 2088 Box of Bricks(脑洞)
传送门: http://acm.hdu.edu.cn/showproblem.php?pid=2088 Box of Bricks Time Limit: 1000/1000 MS (Java/Oth ...
随机推荐
- 趣味ACM题——圣骑士的斩杀
题目来源于山东省第七届ACM大学生程序设计竞赛(Execution of Paladin) 题目描述 鱼人是炉石里的一支强大种族,在探险者协会里,圣骑士有了一张新牌,叫亡者归来,效果是召唤本轮游戏中7 ...
- BZOJ 4695 最假女选手 线段树
题意: 给定一个长度为 N序列,编号从1 到 N.要求支持下面几种操作: 1.给一个区间[L,R] 加上一个数x 2.把一个区间[L,R] 里小于x 的数变成x 3.把一个区间[L,R] 里大于x ...
- 使用sphinx
SQL 结构化查询语言(是一种标准,所有的关系型数据库Mysql,sqlserver,oracle) sphinx的使用两种方式: 第一种: 使用sphinx的API来操作sphinx (常 ...
- HTML5地理定位-Geolocation API
HTML5提供了一组Geolocation API,来自navigator定位对象的子对象,获取用户的地理位置信息Geolocation API使用方法:1.判断是否支持 navigator.geol ...
- stark组件之显示页面内容搭建(六)
之前主要介绍了前端页面list_fiter功能的显示,但是list_display功能的展示并没有过多介绍,这里介绍一下是如何实现的. 可以看到凡是蓝线圈起来的都是通过字段名反射一个个取出来的,红线的 ...
- python3爬虫-爬取58同城上所有城市的租房信息
from fake_useragent import UserAgent from lxml import etree import requests, os import time, re, dat ...
- super在python中有什么用
所属网站分类: python高级 > 面向对象 作者:阿里妈妈 链接:http://www.pythonheidong.com/blog/article/74/ 来源:python黑洞网 有什么 ...
- Webdriver元素定位1
元素的定位应该是自动化测试的核心,要想操作一个元素,首先应该识别这个元素. webdriver提供了一系列的元素定位方法,常用的有以下几种: id name class name tag link t ...
- noip模拟赛 仓库
分析:非常像货车运输那道题.先求一下最大生成树.求完之后会发现并不好处理.通常这类求生成树的题目不会就分析kruscal算法的性质.每往最大生成树中加一条边,如果配重大于这条边权,那么这条边所连的两个 ...
- 1 problem was encountered while building the effective model [FATAL] Non-parseable POM F:\MavenRepository\org\apache\maven\plugins\maven-resources-plugin\2.6\maven-resources-plugin-2.6.pom: start tag
Multiple annotations found at this line: - No plugin found for prefix 'war' in the current project a ...