#27820: CPP


11030067@mail.hpsh.tp.edu.tw (和平110級鄧雨珊)

學校 : 臺北市立和平高級中學
編號 : 163096
來源 : [61.64.210.174]
最後登入時間 :
2022-10-23 16:54:59
c067. 00591 - Box of Bricks -- UVa591 | From: [219.85.1.131] | 發表日期 : 2021-10-31 01:38

#include <iostream>
using namespace std;

int main(){
int n, h[51], set=1;
while (cin >> n){
if (n==0){
break;
}
int sum=0;
for (int i=0; i<n; i++){
cin >> h[i];
sum+=h[i];
}
int avg=sum/n;
int move=0;
for (int i=0; i<n; i++){
if (h[i]>avg){
move+=h[i]-avg;
}
}
cout <<"Set #"<< set++ <<endl;
cout <<"The minimum number of moves is "<< move <<"."<<endl;
}
}
 
ZeroJudge Forum