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 X first
#define Y second
using namespace std;
const int maxn = 1e5+10;
const double inf = 10000000000000;
int n;
long double a[maxn], b[maxn];
int main() {
ios_base::sync_with_stdio(false);
cin.tie();
cin >> n;
for (int i = 0; i < n; i++)
cin >> a[i] >> b[i];
sort(a, a+n); reverse(a, a+n);
sort(b, b+n); reverse(b, b+n);
long double sol = 0;
long double x = 0, y = 0;
int ptrx = 0, ptry = 0;
//a[n] = -inf, b[n] = -inf;
while (ptrx < n || ptry < n) {
//cout << "debug: " << x << " " << y << endl;
//system("pause");
if (x < y && ptrx < n) {
x += a[ptrx++] - 1.0;
y -= 1.0;
} else {
y += b[ptry++] - 1.0;
x -= 1.0;
}
sol = max(sol, min(x, y));
}
printf("%.4lf",(double)sol);
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... |