#include<bits/stdc++.h>
using namespace std;
#define double long double
int main () {
int n,A=0,B=0;cin>>n;
double ans=0.0,sA=0.0,sB=0.0,a[n+1],b[n+1];
for(int i=0;i<n;i++)cin>>a[i]>>b[i];
sort(a,a+n+1);sort(b,b+n+1);
reverse(a, a+n+1);reverse(b, b+n+1);
while(A<=n&&B<=n) {
if(sB<sA)sB+=b[B++];
else sA+=a[A++];
ans = max(ans,min(sA,sB)-A-B);
}
cout<<setprecision(4)<<fixed<<ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Incorrect |
0 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 |
0 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 |
0 ms |
204 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |