제출 #1028171

#제출 시각아이디문제언어결과실행 시간메모리
1028171vjudge1Sure Bet (CEOI17_sure)C++17
100 / 100
66 ms5212 KiB
#include <bits/stdc++.h>

using namespace std;

typedef long double ld;

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

    int n; cin >> n;
    vector<ld> a(n), b(n);
    for(int i = 0; i < n; i++) cin >> a[i] >> b[i];
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    ld paid = 0;
    ld currA = 0;
    ld currB = 0;
    ld ans = 0;
    while(!((currA <= currB && a.empty()) || (currA > currB && b.empty()))){
        paid++;
        if(currA <= currB){
            currA += a.back();
            a.pop_back();
        }else{
            currB += b.back();
            b.pop_back();
        }
        ans = max(ans, min(currA, currB) - paid);
    }
    cout << fixed << setprecision(4) << ans << "\n";
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...