This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define MAXN 100010
using namespace std;
double a[MAXN], b[MAXN];
int main() {
ios::sync_with_stdio(false); cin.tie(0);
int N; cin >> N;
for(int i = 1; i <= N; i++) {
cin >> a[i] >> b[i];
}
sort(a+1, a+1+N);
reverse(a+1, a+1+N);
sort(b+1, b+1+N);
reverse(b+1, b+1+N);
double rez = 0;
int idxa = 1, idxb = 1;
double suma = 0, sumb = 0;
for(int i = 1; i <= 2*N; i++) {
if(idxa == N+1) {
sumb += b[idxb];
idxb++;
} else if(idxb == N+1) {
suma += a[idxa];
idxa++;
} else {
if(suma > sumb) {
sumb += b[idxb];
idxb++;
} else {
suma += a[idxa];
idxa++;
}
}
rez = max(rez, min(suma-i, sumb-i));
}
cout << fixed << setprecision(4) << rez << endl;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |