Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
Re:太水了,这样也敢过。。。In Reply To:太水了,这样也敢过。。。 Posted by:sophlen at 2010-11-10 20:11:39 > #include <cstdlib> > #include <iostream> > #include <algorithm> > > using namespace std; > int n,hi[55]; > > int main(int argc, char *argv[]) > { > int test=0; > while(cin>>n,n){ > test++; > int sum=0; > for(int i=0;i<n;i++){ > cin>>hi[i]; > sum+=hi[i]; > } > sum=sum/n; > sort(hi,hi+n); > int move=0; > for(int i=n-1;i>=0;i--){ > if(hi[i]>sum) move+=hi[i]-sum; > else break; > } > cout<<"Set #"<<test<<endl; > cout<<"The minimum number of moves is "<<move<<'.'<<endl<<endl; > } > return EXIT_SUCCESS; > } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator