#include <bits/stdc++.h>
#define sz(a) (int)a.size()
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
using namespace std;
const int MULT=10000;
signed main() {
    ios_base::sync_with_stdio(false); cin.tie(nullptr);
    int n; cin >> n;
    vector<int> a(n);
    vector<int> b(n);
    for (int i = 0; i < n; i++)
    {
        double _a,_b; cin >> _a >> _b;
        _a*=MULT;
        _b*=MULT;
        a[i]=_a-MULT;
        b[i]=_b-MULT;
    }
    sort(rall(a));
    sort(rall(b));
    int i=0;
    int j=0;
    int lsum=0;
    int rsum=0;
    int mn=0;
    while(i<n||j<n){
        if(lsum<rsum){
            lsum+=a[i];
            rsum-=MULT;
            i++;
        }else{
            rsum+=b[j];
            lsum-=MULT;
            j++;
        }
        mn=max(min(lsum,rsum),mn);
    }
    double ans=(double)mn/(double)MULT;
    cout << setprecision(4) << ans << "\n";
    return 0;
}
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... |