#pragma GCC diagnostic warning "-std=c++11"
#include <bits/stdc++.h>
#define int long long
#define pb push_back
#define f first
#define s second
#define MOD 1000000007
#define flush fflush(stdout)
#define all(x) (x).begin(),(x).end()
#define allr(x) (x).rbegin(), (x).rend()
#define pii pair<int,int>
using namespace std;
int n,m,T,k;
void test_case() {
	cin>>n;
	float a[n+1],b[n+1];
	for (int i=1; i<=n; i++) cin>>a[i]>>b[i];
	sort(a+1,a+1+n); reverse(a+1,a+1+n);
	sort(b+1,b+1+n); reverse(b+1,b+1+n);
	float prefa[n+1],prefb[n+1]; prefa[0]=0; prefb[0]=0;
	for (int i=1; i<=n; i++) {
		prefa[i]=prefa[i-1]+a[i];
		prefb[i]=prefb[i-1]+b[i];
	}
	float ans=0;
	for (int x=0; x<=n*2; x++) {
		float anss=0;
		int l=0,r=x;
		while (l<=r) {
			int mid=(l+r)/2;
			int mid2=x-mid;
			anss=max(anss,min(prefa[mid],prefb[mid2]));
			if (prefa[mid]>prefb[mid2]) {
				r=mid-1;
			}
			else {
				l=mid+1;
			}
		}
		anss-=x;
		ans=max(ans,anss);
	}
	cout<<fixed<<setprecision(5)<<ans<<endl;
}
main () {
	ios :: sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	T=1;
	while (T--) test_case();
}
Compilation message (stderr)
sure.cpp:1:32: warning: '-std=c++11' is not an option that controls warnings [-Wpragmas]
    1 | #pragma GCC diagnostic warning "-std=c++11"
      |                                ^~~~~~~~~~~~
sure.cpp:45:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   45 | main () {
      | ^~~~| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... |