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;
#ifdef LOCAL
#include "debug.h"
#else
#define debug(...) 42
#endif
int main() {
ios::sync_with_stdio(false); cin.tie(nullptr);
int n; cin >> n;
vector<double> a(n), b(n);
for (int i = 0; i < n; ++i) {
cin >> a[i] >> b[i];
}
sort(a.rbegin(), a.rend());
sort(b.rbegin(), b.rend());
double res = 0, A = 0, B = 0;
for (int i = 0, j = 0; i < n && j < n; ) {
if (A < B) {
A += a[i++];
} else {
B += b[j++];
}
res = max(res, min(A, B) - i - j);
}
cout << fixed << setprecision(4) << res;
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... |