UVa 591 Box of Bricks

zz...輕鬆簡單的小題

/*
* UVa 591
* Author: chchwy
* Last Modified: 2009.11.19
*/
#include<cstdio>
int main()
{
int numCase = 1;
int numWall = 0;
while (scanf("%d", &numWall) == 1)
{
if (numWall == 0) break;
int wall[64];
int sum = 0;
for (int i = 0; i < numWall; ++i)
{
scanf("%d", wall + i);
sum += wall[i];
}
int avg = sum / numWall;
int move = 0;
for (int i = 0; i < numWall; ++i)
if (wall[i] > avg)
move += wall[i] - avg;
printf("Set #%d\n", numCase++);
printf("The minimum number of moves is %d.\n\n", move);
}
}
view raw 591.cpp hosted with ❤ by GitHub

留言

  1. hello,
    I'm also solving the UVa 591,
    can you check what's the problem of my idea
    http://ideone.com/eY9w3
    it always shows "Wrong Answer"
    thank you

    回覆刪除

張貼留言

這個網誌中的熱門文章

UVa 10125 Sumsets

讀書心得: 撒哈拉的故事

讀書心得: 你以為你以為的就是你以為的嗎?