#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin>>t;
double ans=0,suma,sumb;
double a[t+1];
double b[t+1];
int a1=0;
int b1=0;
a[0]=0;
b[0]=0;
for(int i=0;i<t;i++){
cin>>a[i];
cin>>b[i];
}
sort(a,a+t);
reverse(a,a+t);
sort(b,b+t);
reverse(b,b+t);
while(a1<=t && b1<=t){
if(sumb<suma){
sumb+=b[b1];
b1++;
}else{
suma+=a[a1];
a1++;
}
ans=max(ans,min(suma-a1-b1,sumb-a1-b1));
}
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 |
- |