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. 使用约束给tableview添加暂无数据的提示

    在tableview没有数据的时候,我们经常需要在tableview的正中间插入一张图片,来提示用户暂无数据 /** * 添加一个view,提示暂无数据 */ - (void)addPromptVie ...

  2. POJ 1458 Common Subsequence(LCS最长公共子序列)

    POJ 1458 Common Subsequence(LCS最长公共子序列)解题报告 题目链接:http://acm.hust.edu.cn/vjudge/contest/view.action?c ...

  3. NotePad++ 配置C/C++编译环境

    如果只是测试小程序可以用这种方法 比较方便,如果对于大程序建议使用专业的IDE. 经常需要写一些小程序来运行,又不想运行Visual Studio.Eclipse这样的环境,而Notepad++是一个 ...

  4. QT自定义对象导入JavaScript脚本使用

    1.对象 项目属性要添加 QT += script自定义的对象头文件如下,实现正常就好,记得脚本里要调用的方法一定要定义在public slots:下,要不然调用时提示该对象没有*方法   #ifnd ...

  5. [LeetCode]题解(python):025-Reverse Nodes in k-Group

    题目来源: https://leetcode.com/problems/reverse-nodes-in-k-group/ 题意分析: 这道题目和上一题目类似,输入一个链表和一个整型k.每k个翻转一下 ...

  6. Agile methodology

    ntroduction Waterfall model follows application development in phases with checkpoint and deliverabl ...

  7. KBMMW SampleService/SampleClient方式传输数据集

    马上周末了,趁着下午这会儿回顾一下这几天对旧项目的升级过程,一些重要但不常用的东西记录下来是很有必要的.其中一个项目中对KBMMW的远程数据通讯方式做了改进,利用SampleService/Sampl ...

  8. 解析request的反馈信息

    Map<String,String> params = new HashMap<String,String>(); Map requestParams = request.ge ...

  9. 利用Mono.Cecil动态修改程序集来破解商业组件(仅用于研究学习)

    原文 利用Mono.Cecil动态修改程序集来破解商业组件(仅用于研究学习) Mono.Cecil是一个强大的MSIL的注入工具,利用它可以实现动态创建程序集,也可以实现拦截器横向切入动态方法,甚至还 ...

  10. java.lang.ClassNotFoundException: javax.servlet.Filter

    java.lang.ClassNotFoundException: javax.servlet.Filter:有两个原因:(1)在maven中的作用域,不能是provided,需要是compile就是 ...