제출 #720310

#제출 시각아이디문제언어결과실행 시간메모리
720310thimote75Sure Bet (CEOI17_sure)C++14
0 / 100
1 ms212 KiB

#include <bits/stdc++.h>

using namespace std;

#define fd vector<float>

int main () {
    ios_base::sync_with_stdio(false); cin.tie(NULL);

    int n;
    cin >> n;

    fd a(n);
    fd b(n);
    for (int i = 0; i < n; i ++)
        cin >> a[i] >> b[i];
    
    sort(a.rbegin(), a.rend());
    sort(b.rbegin(), b.rend());

    int left = 0; int right = 0;
    float c = 0; float d = 0;

    float max_outcome = 0;

    while (left != n && right != n) {
        float v0 = min(c + a[left],  d) - 1;
        float v1 = min(d + b[right], c) - 1;

        c --; d --;
        if (v0 > v1) c += a[left ++];
        else d += b[right ++];

        max_outcome = max(min(c, d), max_outcome);
    }

    printf("%.4lf", (double)max_outcome);
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...