#33376: 請不要參考看看


yp11151138@yphs.tp.edu.tw (801-34許劭頎)

學校 : 臺北市私立延平高級中學
編號 : 197089
來源 : [203.72.178.1]
最後登入時間 :
2024-01-16 09:50:01
c067. 00591 - Box of Bricks -- UVa591 | From: [203.72.178.2] | 發表日期 : 2022-12-30 13:51

#include<bits/stdc++.h>
#define MAX 50
using namespace std;

int main(){
    int n,i,j=1,sum,av,move,h[MAX];
    while(cin>>n,n!=0){
        sum=0;
        for(i=0;i<n;i++) {cin>>h[i]; sum+=h[i];}
        av=sum/n;
        move=0;
        for(i=0;i<n;i++) if(h[i]>av) move+=(h[i]-av);
        cout<<"Set #"<<j++<<endl;
        cout<<"The minimum number of moves is "<<move<<"."<<endl;
    }
    return 0;
}

 
ZeroJudge Forum