제출 #1367758

#제출 시각아이디문제언어결과실행 시간메모리
1367758njoopSure Bet (CEOI17_sure)C++20
100 / 100
70 ms2108 KiB
#include <bits/stdc++.h>

using namespace std;

priority_queue<double> a, b;
double ca, cb, ans;

void cha() {
    ca += a.top()-1;
    cb -= 1;
    a.pop();
}

void chb() {
    cb += b.top()-1;
    ca -= 1;
    b.pop();
}

int main() {
    int n;
    cin >> n;
    for(int i=1; i<=n; i++) {
        double x, y;
        cin >> x >> y;
        a.push(x);
        b.push(y);
    }
    while(!a.empty() || !b.empty()) {
        if(a.empty()) chb();
        else if(b.empty()) cha();
        else if(ca == cb) {
            if(a.top() > b.top()) cha();
            else chb();
        } else if(ca > cb) chb();
        else cha();
        ans = max(ans, min(ca, cb));
    }
    cout << fixed << setprecision(4) << ans;
}
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…