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;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int n;
cin >> n;
vector<double> v_a, v_b;
for (int i = 0; i < n; i++) {
double a, b;
cin >> a >> b;
v_a.push_back(a);
v_b.push_back(b);
}
sort(v_a.rbegin(), v_a.rend());
sort(v_b.rbegin(), v_b.rend());
double a = 0.0, b = 0.0, ans = 0.0;
for (int x = 0, y = 0; x <= n; x++) {
if (x > 0) a += v_a[x - 1] - 1, b -= 1.0;
while (y < n && a - b > 1e-7) {
ans = max(ans, min(a, b));
b += v_b[y++] - 1, a -= 1.0;
}
ans = max(ans, min(a, b));
}
cout << fixed << setprecision(4) << ans << '\n';
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... |