//order_of_key (k) : Number of items strictly smaller than k .
//find_by_order(k) : K-th element in a set (counting from zero).
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define ordered_set tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>
#define int long long
#define pii pair<int,int>
#define F first
#define S second
#define pb push_back
#define len(x) (int)x.size()
#define pf push_front
#define popb pop_back
#define popf pop_front
#define all(x) (x).begin(), (x).end()
#pragma GCC target( "sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#pragma GCC optimize("Ofast,unroll-loops,fast-math,O3")
using namespace std;
using namespace __gnu_pbds;
const int N = 1e6 + 5;
const int mod = 1e9 + 7;
const int inf = 1e18;
double a[N] , b[N] , suf1[N] , suf2[N] ;
signed main(/*Nurali*/){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	int n;
	
	cin >> n;
	
	for(int i = 1;i<=n;i++){
		cin >> a[i];
		cin >> b[i];
	}
	
	sort(a + 1, a + n + 1);
	sort(b + 1, b + n + 1);
	
	double ans = 0;
	
	for(int i = n;i>=1;i--){
		suf1[i] = a[i] + suf1[i+1];
	}
	
	for(int i = n;i>=1;i--){
		suf2[i] = b[i] + suf2[i+1];
	}
	
	for(int i = n;i>=1;i--){
		for(int j = n;j>=1;j--){
			ans = max(min(suf1[i] - (n-i+1+n-j+1),suf2[j] - (n-i+1+n-j+1)), ans);
		}
	}	
	
	setprecision(4);
	
	cout << fixed << ans;
}
/*
//order_of_key(k): Number of items strictly smaller than k .
//find_by_order(k): K-th element in a set (counting from zero).
//sum of squares n*(n+1)*(2n+1)/6
//sum of cubes [n*(n+1)/2]^2
//sum of squares for odds n*(4*n*n-1)/3
//sum of cubes for odds n*n*(2*n*n-1)
//a/b%mod = a*(b^(m-2)%mod)
//(a>>x)&1 == 0
//a^b = (a+b)-2(a&b)
//srand(time(0))-always changing
bool cmp(pii a,pii b){
	if (a.F == b.F){
		return a.S < b.S;
	}
//	if (a.F > b.F) return 1;
//	else return 0;
	return a.F > b.F;
}
  sisteme 101010
  for(char c : s)
  x = x*k + (c-48);
	*/
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... |