/// Raihan Ruhin /// CSE, Jahangirnagar University. /// Dhaka-Bangladesh. /// id: raihanruhin (topcoder / codeforces / codechef / hackerrank / uva / uvalive / spoj), 3235 (lightoj) /// mail: raihanruhin@ (yahoo / gmail / facebook) /// blog: ruhinraihan.blogspot.com #include<bits/stdc++.h> using namespace std; #define SET(a) memset(a,-1,sizeof(a)) #define CLR(a) memset(a,0,sizeof(a)) #define PI acos(-1.0) #define MOD 1000000007 #define MX 100010 int main() { ios_base::sync_with_stdio(0);cin.tie(0); int n, tc, kk=1; double arr[1005], avg, tot, ans1, ans2; string s; while(cin>>n && n) { tot=0; for(int i=0;i<n;i++) { cin>>arr[i]; tot+=arr[i]; } avg=tot/(double)n; ans1=ans2=0; //cout<<avg<<endl; for(int i=0;i<n;i++) { double dif = (double) (long long) ((arr[i]-avg)*100.0)/100.0 ; if(dif>0) ans1+=dif; else ans2-=dif; } tot=max(ans1, ans2); cout<<"$"<<setprecision(2)<<fixed<<tot<<"\n"; } return 0; }
Thursday, 9 April 2015
UVA 10137 The Trip (ZOJ 1847, POJ 2646)
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment