Submission #504125

# Submission time Handle Problem Language Result Execution time Memory
504125 2022-01-09T21:45:03 Z t0nhou Sure Bet (CEOI17_sure) C++17
100 / 100
90 ms 3524 KB
#include <bits/stdc++.h>
#define endl '\n'

using namespace std;

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

    int n; cin >> n;

    vector<double> l(n), r(n);
    for(int i = 0; i < n; i++)
        cin >> l[i] >> r[i];

    sort(l.begin(), l.end()); sort(r.begin(), r.end());
    reverse(l.begin(), l.end()); reverse(r.begin(), r.end());

    int q1 = 1, q2 = 1;
    double s1 = l[0], s2 = r[0];
    double maior = max((double)0, min(s1 - 2, s2 - 2));

    while(true){
        if(s1 < s2){
            if(q1 >= n || l[q1] == 1) break;
            s1 += l[q1];
            q1++;
        }else{
            if(q2 >= n || r[q2] == 1) break;
            s2 += r[q2];
            q2++;
        }
        maior = max(maior, min(s1 - (q1+q2), s2 - (q1+q2)));
    }

    cout.precision(4);
    cout << fixed;

    cout << maior << endl;

    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 312 KB Output is correct
4 Correct 0 ms 312 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 312 KB Output is correct
4 Correct 0 ms 312 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 0 ms 312 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 2 ms 320 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 2 ms 320 KB Output is correct
15 Correct 1 ms 324 KB Output is correct
16 Correct 1 ms 332 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 312 KB Output is correct
4 Correct 0 ms 312 KB Output is correct
5 Correct 0 ms 204 KB Output is correct
6 Correct 0 ms 204 KB Output is correct
7 Correct 0 ms 204 KB Output is correct
8 Correct 0 ms 204 KB Output is correct
9 Correct 0 ms 312 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 2 ms 320 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 2 ms 320 KB Output is correct
15 Correct 1 ms 324 KB Output is correct
16 Correct 1 ms 332 KB Output is correct
17 Correct 71 ms 3140 KB Output is correct
18 Correct 90 ms 3132 KB Output is correct
19 Correct 68 ms 3132 KB Output is correct
20 Correct 68 ms 3136 KB Output is correct
21 Correct 75 ms 3524 KB Output is correct
22 Correct 69 ms 3132 KB Output is correct
23 Correct 72 ms 3140 KB Output is correct
24 Correct 69 ms 3144 KB Output is correct
25 Correct 74 ms 3140 KB Output is correct
26 Correct 79 ms 3524 KB Output is correct