답안 #468704

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
468704 2021-08-29T12:24:49 Z Josia Sure Bet (CEOI17_sure) C++17
100 / 100
102 ms 3760 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;

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

    while (p1 < n || p2<n) {
        if (p1==n) p2++;
        else if (p2==n) p1++;

        else if (pfs1[p1] <= pfs2[p2]) p1++; // better heuristic?
        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 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 1 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 1 ms 332 KB Output is correct
17 Correct 90 ms 3656 KB Output is correct
18 Correct 91 ms 3760 KB Output is correct
19 Correct 91 ms 3660 KB Output is correct
20 Correct 92 ms 3640 KB Output is correct
21 Correct 98 ms 3760 KB Output is correct
22 Correct 92 ms 3656 KB Output is correct
23 Correct 92 ms 3656 KB Output is correct
24 Correct 94 ms 3640 KB Output is correct
25 Correct 92 ms 3556 KB Output is correct
26 Correct 102 ms 3760 KB Output is correct