답안 #467364

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
467364 2021-08-22T18:01:06 Z idk321 Sure Bet (CEOI17_sure) C++17
60 / 100
95 ms 3668 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

const int N = 100005;
double odds [2][N];



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

    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> odds[0][i] >> odds[1][i];
    }
    sort(odds[0], odds[0] + n, greater<double>());
    sort(odds[1], odds[1] + n, greater<double>());

    double res = 0;
    double val1 = 0;
    double val2 = 0;
    int a =  0;
    int b =  0;
    for (int i = 0; i < 2 * n; i++) {
        if (i == 0) {
            val1 += odds[0][a];
            a++;
            res = max(res, min(val1, val2) - a - b);
        } else {
            if (val1 < val2 && a != n) {
                val1 += odds[0][a];
                a++;
                res = max(res, min(val1, val2) - a - b);
            } else {
                val2 += odds[1][b];
                b++;
                res = max(res, min(val1, val2) - a - b);
            }
        }
    }

    cout << fixed << setprecision(4) << res << "\n";
}

/*
4
1.4 3.7
1.2 2
1.6 1.4
1.9 1.5
*/
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 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 0 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 2 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 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 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 0 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 2 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 86 ms 1864 KB Output is correct
18 Correct 92 ms 3176 KB Output is correct
19 Correct 88 ms 3200 KB Output is correct
20 Correct 88 ms 3120 KB Output is correct
21 Incorrect 95 ms 3668 KB Output isn't correct
22 Halted 0 ms 0 KB -