http://www.bnuoj.com/bnuoj/problem_show.php?pid=1596

这个题一开始以为要求最少移动次数,把我吓到了,原来只要求最少移动几个方块就行了。。这一下就变简单很多了。。

AC代码:
#include<iostream>
#include<cstdio>
#include<algorithm> using namespace std; bool cmp(int a, int b)
{
return a<b;
} int main()
{
int n,i,k,sum,p;
int a[55];
k = 0;
while(scanf("%d",&n)&&n)
{
k++;
sum = 0;
for(i = 0; i < n; i++)
{
scanf("%d",&a[i]);
sum += a[i];
}
sum = sum/n;
sort(a,a+n,cmp);
p = 0;
for(i = 0; i < n; i++)
{
if(a[i] < sum)
{
p+=(sum-a[i]);
}
else
{
break;
}
}
printf("Set #%d\n",k);
printf("The minimum number of moves is %d.\n\n",p);
} return 0;
}

BNU Box of Bricks的更多相关文章

  1. HDOJ 1326. Box of Bricks 纯水题

    Box of Bricks Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) To ...

  2. Box of Bricks最小移动砖块数目

    Description Little Bob likes playing with his box of bricks. He puts the bricks one upon another and ...

  3. [POJ1477]Box of Bricks

    Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 19503   Accepted: 7871 Description Litt ...

  4. HDOJ(HDU) 2088 Box of Bricks(平均值)

    Problem Description Little Bob likes playing with his box of bricks. He puts the bricks one upon ano ...

  5. HDOJ 1326 Box of Bricks(简单题)

    Problem Description Little Bob likes playing with his box of bricks. He puts the bricks one upon ano ...

  6. 591 - Box of Bricks

     Box of Bricks  Little Bob likes playing with his box of bricks. He puts the bricks one upon another ...

  7. Box of Bricks

    Box of Bricks Time Limit : 2000/1000ms (Java/Other)   Memory Limit : 65536/32768K (Java/Other) Total ...

  8. HDU 2088 Box of Bricks

    http://acm.hdu.edu.cn/showproblem.php?pid=2088 Problem Description Little Bob likes playing with his ...

  9. HDU 2088 Box of Bricks(脑洞)

    传送门: http://acm.hdu.edu.cn/showproblem.php?pid=2088 Box of Bricks Time Limit: 1000/1000 MS (Java/Oth ...

随机推荐

  1. D - 1sting(相当于斐波那契数列,用大数写)

    Description You will be given a string which only contains ‘1’; You can merge two adjacent ‘1’ to be ...

  2. [LeetCode]题解(python):011-Container With Most Water

    题目来源: https://leetcode.com/problems/container-with-most-water/ 题意分析: 给出一个n长度的非0数组,a1,a2,……,an,ai代表在坐 ...

  3. poj 1850/poj 1496

    http://poj.org/problem?id=1850 -----------------http://poj.org/problem?id=1496 两题解法类似..本题为组合数学的题,要求所 ...

  4. (转)requirejs:杏仁的优化(almond)

    使用场景 什么情况下需要使用 almond 呢?假设你手头有个基于requirejs的小项目,所有业务代码加起来就几十K(压缩后可能更小).出于性能优化的考虑,你可能在想:如果能够去掉requirej ...

  5. 安装CDH

    Cloudera Manager 4.8.2 http://www.idefs.com/recordsubuntu-12-04-cloudera-installation-manager-4-8-2- ...

  6. 第三节 ISBN 码 / ISSN 码

    ISBN与ISSNEAN的用途很广,除了我国的商品条码CAN以及日本商品条码JAN外,目前国际认可的书籍代号与期刊号的条码,也都是由EAN变身而来的.书籍的国际认可代号称为国际标准书号(Interna ...

  7. PROTEL99 SE生成的gerber 与ncdrill的坐标不对应

    导入cam350后的: 解决方法:出gerber的时候在高级选项里面. 1.数据单位及格式 2.优化设置

  8. c++ ptrdiff_t 类型

    ptrdiff_t是C/C++标准库中定义的一个与机器相关的数据类型.ptrdiff_t类型变量通常用来保存两个指针减法操作的结果.ptrdiff_t定义在stddef.h(cstddef)这个文件内 ...

  9. Treasure Exploration(二分最大匹配+floyd)

    Treasure Exploration Time Limit: 6000MS   Memory Limit: 65536K Total Submissions: 7455   Accepted: 3 ...

  10. Arcgis for javascript map操作addLayer具体解释

    本节的内容非常easy.说说Arcgis for Javascript里面map对象的addLayer方法.在for JS的API中,addLayer方法有两种.例如以下图: watermark/2/ ...