Last active
November 3, 2015 09:44
-
-
Save knuu/b74a6fa4ac5b6b098810 to your computer and use it in GitHub Desktop.
Codeforces Round #204(Div. 1) - A. Jeff and Rounding
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <bits/stdc++.h> | |
using namespace std; | |
#define FOR(i,s,x) for(int i=s;i<(int)(x);i++) | |
#define REP(i,x) FOR(i,0,x) | |
int main() { | |
// use scanf in CodeForces! | |
cin.tie(0); | |
ios_base::sync_with_stdio(false); | |
int N, cnt = 0; | |
double sum = 0.0; | |
cin >> N; | |
REP(i, 2 * N) { | |
double a; | |
cin >> a; | |
if (a != floor(a)) { | |
sum += a - floor(a); | |
} else { | |
cnt++; | |
} | |
} | |
double ans = 2000; | |
if (cnt <= N) { | |
FOR(i, N - cnt, N+1) { | |
ans = min(ans, abs(i - sum)); | |
} | |
} else { | |
REP(i, cnt + 1) { | |
ans = min(ans, abs(i - sum)); | |
} | |
} | |
printf("%.3lf\n", ans); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment