Submission #467566

# Submission time Handle Problem Language Result Execution time Memory
467566 2021-08-23T17:14:11 Z idk321 Sure Bet (CEOI17_sure) C++17
100 / 100
97 ms 3524 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

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

double sum[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 val2 = odds[1][0];
    int j = 0;
    double res = 0;
    double val1 = 0;
    for (int i = 0; i < n; i++) {
        val1 += odds[0][i];


        while (j + 1 < n && (min(val1, val2)- i - j - 2) < (min(val1, val2 + odds[1][j + 1]) - i - j - 3)) {
            j++;
            val2 += odds[1][j];
        }

        res = max(res, min(val1, val2)- i - j - 2);
    }

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

/*
4
1.4 3.7
1.2 2
1.6 1.4
1.9 1.5
*/
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 324 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 320 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 2 ms 352 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 352 KB Output is correct
16 Correct 1 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 332 KB Output is correct
2 Correct 1 ms 332 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 332 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 324 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 320 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 2 ms 352 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 352 KB Output is correct
16 Correct 1 ms 332 KB Output is correct
17 Correct 88 ms 3324 KB Output is correct
18 Correct 94 ms 3116 KB Output is correct
19 Correct 97 ms 3228 KB Output is correct
20 Correct 85 ms 3168 KB Output is correct
21 Correct 92 ms 3484 KB Output is correct
22 Correct 83 ms 3208 KB Output is correct
23 Correct 88 ms 3232 KB Output is correct
24 Correct 85 ms 3216 KB Output is correct
25 Correct 83 ms 3140 KB Output is correct
26 Correct 92 ms 3524 KB Output is correct