#include<bits/stdc++.h>
using namespace std;
int main () {
int n, A = 0, B = 0;cin>>n;
long double ans = 0.0, sumA = 0.0, sumB = 0.0;
long double a[n+1], b[n+1];
for(int i = 0;i<n;i++){
cin>>a[i]>>b[i];
}
sort(a, a+n, greater<long double> ());sort(b, b+n, greater<long double> ());
while(A < n and B < n)
{
if(sumA < sumB) {
sumA += a[A++];
}
else {
sumB += b[B++];
}
ans = max(ans, min(sumA, sumB) - (long double)(A) - (long double)(B));
}
printf("%.4lf",(double)ans);
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Incorrect |
1 ms |
204 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |