이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
using db = double;
int32_t main() {
int n;
cin >> n;
vector<db> a(n), b(n);
db ans = 0, sa = 0, sb = 0;
for (int i = 0; i < n; i++) cin >> a[i] >> b[i];
sort(a.rbegin(), a.rend());
sort(b.rbegin(), b.rend());
int pa = 0, pb = 0;
for (int i = 1; i <= 2 * n; i++) {
if (sa <= sb && pa < n) sa += a[pa++];
else if (sb <= sa && pb < n) sb += b[pb++];
ans = max(ans, min(sa, sb) - i);
}
cout << fixed << setprecision(4) << ans << '\n';
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |