-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuva591.txt
45 lines (42 loc) · 968 Bytes
/
uva591.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<string>
#include<stdlib.h>
#include<math.h>
#include<algorithm>
#include<map>
#define pi acos(0.0)
#define maxi 1010
using namespace std;
int main()
{
int tcase=0,i,j,k,n,count,brick[1000],wall,move,ans;
while(scanf("%d", &n)==1&&n!=0)
{
tcase++;
ans=0;
count=0;
for(i=0;i<n;i++)
{
scanf("%d", &brick[i]);
ans=ans+brick[i];
//printf("ans %d\n", ans);
}
wall=ans/n;
//printf("wall %d\n", wall);
for(j=0;j<n;j++)
{
if(brick[j]>wall)
{
move=brick[j]-wall;
//printf("move %d\n", move);
count=count+move;
//printf("count %d\n", count);
}
}
printf("Set #%d\n", tcase);
printf("The minimum number of moves is %d.\n", count);
printf("\n");
}
}