提交记录
提交记录
代码
#include<bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
double a[N],b[N],ans,suma,sumb;
int n;
bool cmp(double x,double y){
return x > y;
}
int main(){
cin >> n;
for(int i = 1;i <= n;i ++){
cin >> a[i] >> b[i];
}
sort(a + 1,a + n + 1,cmp);
sort(b + 1,b + n + 1,cmp);
for(int l = 1,r = 0;l <= n;l ++){
suma += a[l];
while(r < n and sumb < suma){
sumb += b[++r];
}
ans = max(ans,min(suma,sumb) - l - r);
}
cout << fixed << setprecision(4) << ans;
return 0;
}