#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using graph = vector<vector<int>>;
int main() {
ios::sync_with_stdio(false), cin.tie(nullptr);
int N;
cin >> N;
vector<double> a(N), b(N);
for (auto &x : a) cin >> x;
for (auto &x : b) cin >> x;
sort(a.begin(), a.end(), greater<>());
sort(b.begin(), b.end(), greater<>());
double ans = 0;
int bets_taken = 0;
int ap = 0, bp = 0;
double a_sum = 0, b_sum = 0;
for (int i = 0; i < 2 * N; ++i) {
if (ap < N && bp < N) {
if (a_sum < b_sum) {
a_sum += a[ap++];
} else {
b_sum += b[bp++];
}
} else if (ap < N) {
a_sum += a[ap++];
} else if (bp < N) {
b_sum += b[bp++];
} else {
assert(0);
}
++bets_taken;
ans = max(ans, min(a_sum, b_sum) - bets_taken);
}
cout << fixed << setprecision(4) << ans << endl;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Incorrect |
0 ms |
320 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Incorrect |
0 ms |
320 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Incorrect |
0 ms |
320 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |