답안 #468703

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
468703 2021-08-29T12:10:03 Z Josia Sure Bet (CEOI17_sure) C++14
0 / 100
1 ms 204 KB
#include <bits/stdc++.h>

#define int int64_t

using namespace std;




signed main() { // they may not be all connected!!!
    cin.tie(0);
    ios_base::sync_with_stdio(0);


    int n; cin >> n;

    vector<double> bets1(n);
    vector<double> bets2(n);

    for (int i = 0; i<n; i++) {
        cin >> bets1[i] >> bets2[i];
    }


    sort (bets1.begin(), bets1.end());
    sort (bets2.begin(), bets2.end());

    reverse(bets1.begin(), bets1.end());
    reverse(bets2.begin(), bets2.end());


    vector<double> pfs1={0}, pfs2={0};

    for (int i = 0; i<n; i++) {
        pfs1.push_back(pfs1.back()+bets1[i]);
        pfs2.push_back(pfs2.back()+bets2[i]);
    }

    double res = 0;
    
    double p1 = 1;
    double p2 = 1;
    while (p1 < n && p2<n) {
        if (pfs1[p1] <= pfs2[p2]) p1++;
        else p2++;

        res = max(res, min(pfs1[p1]-p1-p2, pfs2[p2]-p1-p2));
    }


    p1 = 1;
    p2 = 1;
    while (p1 < n && p2<n) {
        if (pfs1[p1] < pfs2[p2]) p1++;
        else p2++;

        res = max(res, min(pfs1[p1]-p1-p2, pfs2[p2]-p1-p2));
    }



    printf("%.4lf\n",(double)res);


    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Incorrect 1 ms 204 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Incorrect 1 ms 204 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Incorrect 1 ms 204 KB Output isn't correct
3 Halted 0 ms 0 KB -