#include <bits/stdc++.h>
using namespace std;
const int buff = 100000;
const long double dick = 1.0;
long long A[100008], B[100008];
signed main() {
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
int n; long double x; cin >> n;
for (int i = 1; i <= n; ++i) cin >> x, A[i] = round(x * buff);
for (int i = 1; i <= n; ++i) cin >> x, B[i] = round(x * buff);
sort(A + 1, A + n + 1, greater<long long>()); sort(B + 1, B + n + 1, greater<long long>());
for (int i = 1; i <= n; ++i) A[i] += A[i - 1];
for (int i = 1; i <= n; ++i) B[i] += B[i - 1];
int j; long double ans = 0;
for (int i = 1; i <= n && A[i] <= B[n]; ++i) { // A[i] <= B[j]
j = lower_bound(B + 1, B + n + 1, A[i]) - B;
ans = max(ans, (A[i] * dick) / buff - i - j);
}
for (int i = 1; i <= n && B[i] <= A[n]; ++i) { // B[i] <= A[j]
j = lower_bound(A + 1, A + n + 1, B[i]) - A;
ans = max(ans, (B[i] * dick) / buff - i - j);
}
cout << fixed << setprecision(4) << ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |