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 all(a) begin(a), end(a)
using namespace std;
void solve() {
int n;
cin >> n;
vector<double> v[2];
v[0].resize(n);
v[1].resize(n);
for (int i = 0; i < n; ++i) {
cin >> v[0][i] >> v[1][i];
}
sort(all(v[0]), greater<>());
sort(all(v[1]), greater<>());
double ans = 0;
double cur[2] = {0, 0};
int p = 0;
for (int i = 0; i < n; ++i) {
cur[0] += v[0][i] - 1;
cur[1] -= 1;
ans = max(ans, min(cur[0], cur[1]));
while (p < n && cur[1] < cur[0]) {
cur[1] += v[1][p] - 1;
cur[0] -= 1;
ans = max(ans, min(cur[0], cur[1]));
++p;
}
}
cout << ans << '\n';
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cout << fixed << setprecision(4);
solve();
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... |