blob: bd4d0475a65172534021aa774e39c8a65a3debd9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
#include <stdio.h>
int main(){
int n, j=0;
scanf("%d", &n);
while(n>0){
j++;
int heights[100], avg, sum=0, i, moves=0, move, h;
for(i=0; i<n; i++){
scanf("%d", &h);
sum+=h;
heights[i]=h;
}
avg = sum/n;
for(i=0; i<n; i++){
move = avg-heights[i];
moves += (move < 0 ? move*-1 : move);
}
printf("Set #%d\nThe minimum number of moves is %d.\n\n", j, moves/2);
scanf("%d", &n);
}
return 0;
}
|