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>
using namespace std;
using ll = long long;
int main () {
int n;
cin >> n;
vector<ll> a (n), b (n);
for (int i = 0; i < n; i++) {
double x, y;
cin >> x >> y;
a[i] = round(x*10000);
b[i] = round(y*10000);
}
sort(a.rbegin(), a.rend());
sort(b.rbegin(), b.rend());
ll ans = 0;
ll cura = 0, curb = 0;
for (int i = 0, j = 0; i < n; i++) {
cura += a[i] - 10000;
curb -= 10000;
while (j < n && cura-10000 > curb+b[j]-10000) {
cura -= 10000;
curb += b[j] - 10000;
j++;
}
ans = max(ans, curb);
if (j < n) ans = max(ans, min(cura-10000, curb+b[j]-10000));
}
printf("%.4lf", (double) ans/10000);
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... |