Submission #1331890

#TimeUsernameProblemLanguageResultExecution timeMemory
1331890uranhishigSure Bet (CEOI17_sure)C++20
0 / 100
1 ms344 KiB
#include <bits/stdc++.h>
using namespace std;
#define int long long

signed main(){
    int n;
    cin >> n;
    vector<double> a(n), b(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i] >> b[i];
    }
    sort(a.rbegin(), a.rend());
    sort(b.rbegin(), b.rend());
    vector<double> pa(n + 1);
    vector<double> pb(n + 1);
    for (int i = 0; i <= n; i++) {
        pa[i] = 0.0;
    }
    for (int i = 0; i <= n; i++) {
        pb[i] = 0.0;
    }
    for (int i = 1; i <= n; i++) {
        pa[i] = pa[i - 1] + a[i - 1];
        pb[i] = pb[i - 1] + b[i - 1];
    }
    double ans = 0.0;
    for (int i = 0; i <= n; i++) {
        for (int j = 0; j <= n; j++) {
            if(i + j > n) continue;
            int x = i + j;
            double d1 = pa[i] - x;
            double d2 = pb[j] - x;
            ans = max(ans, min(d1, d2));
        }
    }
    cout << fixed << setprecision(9) << ans;
    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...