#include <bits/stdc++.h>
using namespace std;
#define double long double
#define all(x) x.begin(),x.end()
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
int n;cin>>n;
vector<double> a(n+1),b(n+1);
for(int i=0;i<n;i++){
cin>>a[i]>>b[i];
}
a[n]=0;
b[n]=0;
sort(all(a),greater<>());
sort(all(b),greater<>());
double total1=0,total2=0;
int ptr1=0,ptr2=0;
double ans=0;
for(;ptr1<n&&ptr2<n;){
if(total1<total2||ptr2==n){
total1+=a[ptr1++];
}
else{
total2+=b[ptr2++];
}
total1-=1;
total2-=1;
ans=max(min(total1,total2),ans);
}
cout<<fixed<<setprecision(4)<<ans<<endl;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |