#include<bits/stdc++.h>
using namespace std;
int main () {
long long n,Ai=0,Bi=0;cin>>n;
long 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);sort(b,b+n);
reverse(a,a+n);reverse(b,b+n);
while(Ai<=n && Bi<=n) {
if(sB<sA)sB+=b[Bi],Bi++;
else sA+=a[Ai],Ai++;
ans = max(ans,min(sA-Ai-Bi,sB-Ai-Bi));
}
cout.precision(4);
cout<<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 |
- |