#include <bits/stdc++.h>
using namespace std;
const int N=1e5+4;
double a[N],b[N];
signed main(){
ios::sync_with_stdio(0);
cin.tie(0);
int n;
cin>>n;
for(int i=0;i<n;++i){
cin>>a[i]>>b[i];
}
sort(a,a+n,greater<double>());
sort(b,b+n,greater<double>());
double si=0,sj=0,ans=0;
int i=0,j=0;
for(int k=1;k<=2*n;++k){
if((si<sj||j>=n)&&i<n)si+=a[i++];
else sj+=b[j++];
double x=min(si,sj)-(1.0*k);
ans=max(ans,x);
}
printf("%.4lf",(double)ans);
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |