#include <bits/stdc++.h>
using namespace std;
int32_t main(){
int n; cin >> n;
vector<double> a, b;
for(int i = 0; i < n; i++){
int v; cin >> v; a.push_back(v);
}
for(int i = 0; i < n; i++){
int v; cin >> v; b.push_back(v);
}
sort(a.begin(), a.end(), [](int x, int y){ return x > y; });
sort(b.begin(), b.end(), [](int x, int y){ return x > y; });
vector<double> sa(n + 1), sb(n + 1);
for(int i = 0; i < n; i++) sa[i + 1] = sa[i] + a[i];
for(int i = 0; i < n; i++) sb[i + 1] = sb[i] + b[i];
int L = 0, R = 0;
double ans = 0;
while(L < n || R < n){
if(R == n || L < n && sa[L] < sb[R]) L++;
else R++;
ans = max(ans, min(sa[L], sb[R]) - (L + R));
}
cout << fixed << setprecision(10) << ans << endl;
}
Compilation message
sure.cpp: In function 'int32_t main()':
sure.cpp:27:24: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
27 | if(R == n || L < n && sa[L] < sb[R]) L++;
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |