#include <bits/stdc++.h>
using namespace std;
// #pragma GCC optimize("Ofast,unroll-loops,no-stack-protector")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4.1,sse4.2,sse4a,abm,mmx,avx,avx2,fma,popcnt,tune=native")
#define int long long
#define qweqdasd ios_base::sync_with_stdio(0), cin.tie(0)
#define pb push_back
#define st first
#define nd second
#define watch(x) (cout << #x << " == " << x << '\n')
mt19937_64 rng(147098291);
random_device rd;
mt19937_64 mersenne(rd());
const int maxn = 1e6 + 7;
const int mod = 1e9 + 7;
const int mod2 = (119 << 23) + 1; // 998244353
const int inf = 1e18;
const double eps = 1e-7;
const int block = 350;
const int dx[] = { -1, 1, 0, 0, -1, -1, 1, 1 };
const int dy[] = { 0, 0, -1, 1, -1, 1, -1, 1 };
int a[maxn];
void solve()
{
    int n;
    cin >> n;
    vector<pair<double, double>> vec;
    for (int i = 1; i <= n; ++i) {
        double x, y;
        cin >> x >> y;
        vec.pb({ x, y });
    }
    vector<pair<double, double>> sortf = vec;
    sort(sortf.begin(), sortf.end(), [](const pair<double, double>& ff, const pair<double, double>& ss) {
        return ff.first > ss.first;
    });
    vector<pair<double, double>> sorts = vec;
    sort(sorts.begin(), sorts.end(), [](const pair<double, double>& ff, const pair<double, double>& ss) {
        return ff.second > ss.second;
    });
    double preff[n + 1], prefs[n + 1];
    preff[0] = prefs[0] = 0;
    for (int i = 1; i <= n; ++i) {
        preff[i] = preff[i - 1] + sortf[i - 1].first;
    }
    for (int i = 1; i <= n; ++i) {
        prefs[i] = prefs[i - 1] + sorts[i - 1].second;
    }
    // for (auto tt : sortf) {
    //     cout << tt.first << ' ' << tt.second << '\n';
    // }
    // cout << '\n';
    // for (auto tt : sorts) {
    //     cout << tt.first << ' ' << tt.second << '\n';
    // }
    double rs = 0;
    // for (int i = 1; i <= n; ++i) {
    //     cout << preff[i] << ' ';
    // }
    // cout << '\n';
    // for (int i = 1; i <= n; ++i) {
    //     cout << prefs[i] << ' ';
    // }
    // cout << '\n';
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= n; ++j) {
            rs = max(rs, min(prefs[j] - (j + i), preff[i] - (i + j)));
        }
    }
    cout << setprecision(4) << fixed << max(rs, 0.0);
}
int32_t main()
{
    qweqdasd;
    int tests = 1;
    // cin >> tests;
    for (int i = 1; i <= tests; ++i) {
        // cout << "Case " << i << ":\n";
        solve();
    }
#ifdef LOCAL
    cerr << '\n'
         << "fnshd in " << clock() * 1.0 / CLOCKS_PER_SEC << " s\n";
#endif
}
/**
 *
 */
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... |