Skip to content

Instantly share code, notes, and snippets.

@knuu
Last active November 3, 2015 09:44
Show Gist options
  • Save knuu/b74a6fa4ac5b6b098810 to your computer and use it in GitHub Desktop.
Save knuu/b74a6fa4ac5b6b098810 to your computer and use it in GitHub Desktop.
Codeforces Round #204(Div. 1) - A. Jeff and Rounding
#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