Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

Re:太水了,这样也敢过。。。

Posted by hnly at 2011-07-19 19:54:13 on Problem 1477
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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator