Submission #107919

#TimeUsernameProblemLanguageResultExecution timeMemory
107919kingfran1907Sure Bet (CEOI17_sure)C++14
60 / 100
135 ms5240 KiB
#include <bits/stdc++.h>
#define X first
#define Y second
 
using namespace std;
const int maxn = 1e5+10;
const double inf = 10000000000000;
 
int n;
long double a[maxn], b[maxn];
 
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie();
 
    cin >> n;
    for (int i = 0; i < n; i++)
        cin >> a[i] >> b[i];
 
    sort(a, a+n); reverse(a, a+n);
    sort(b, b+n); reverse(b, b+n);
 
    long double sol = 0;
    long double x = 0, y = 0;
    int ptrx = 0, ptry = 0;
    //a[n] = -inf, b[n] = -inf;
    while (ptrx < n || ptry < n) {
        //cout << "debug: " << x << " " << y << endl;
        //system("pause");
        if (x < y && ptrx < n) {
            x += a[ptrx++] - 1.0;
            y -= 1.0;
        } else {
            y += b[ptry++] - 1.0;
            x -= 1.0;
        }
        sol = max(sol, min(x, y));
    }
    cout << fixed << setprecision(4) << sol << endl;
    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...