#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;
}
# |
Verdict |
Execution time |
Memory |
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 |
- |
# |
Verdict |
Execution time |
Memory |
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 |
- |
# |
Verdict |
Execution time |
Memory |
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 |
- |