이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
int n, L = 0, R = 0;
double a[100010], b[100010], A = 0, B = 0, ans = 0;
int main() {
iostream::sync_with_stdio(0); cin.tie(0);
cin >> n;
for(int i = 0; i < n; i++) cin >> a[i] >> b[i];
sort(a, a + n, greater<double> ());
sort(b, b + n, greater<double> ());
while(L < n && R < n) {
if(A < B) {
A += a[L] - 1.0, B -= 1.0;
ans = max(ans, min(A, B)), L++;
}
else {
B += b[R] - 1.0, A -= 1.0;
ans = max(ans, min(A, B)), R++;
}
}
while(L < n) {
A += a[L] - 1.0, B -= 1.0;
ans = max(ans, min(A, B)), L++;
}
while(R < n) {
B += b[R] - 1.0, A -= 1.0;
ans = max(ans, min(A, B)), R++;
}
cout << fixed << setprecision(4) << ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |