Submission #380708

# Submission time Handle Problem Language Result Execution time Memory
380708 2021-03-22T20:22:00 Z MladenP Sure Bet (CEOI17_sure) C++17
100 / 100
92 ms 3820 KB
#include <bits/stdc++.h>
#define MAXN 100010
using namespace std;
double a[MAXN], b[MAXN];
int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    int N; cin >> N;
    for(int i = 1; i <= N; i++) {
        cin >> a[i] >> b[i];
    }
    sort(a+1, a+1+N);
    reverse(a+1, a+1+N);
    sort(b+1, b+1+N);
    reverse(b+1, b+1+N);
    double rez = 0;
    int idxa = 1, idxb = 1;
    double suma = 0, sumb = 0;
    for(int i = 1; i <= 2*N; i++) {
        if(idxa == N+1) {
            sumb += b[idxb];
            idxb++;
        } else if(idxb == N+1) {
            suma += a[idxa];
            idxa++;
        } else {
            if(suma > sumb) {
                sumb += b[idxb];
                idxb++;
            } else {
                suma += a[idxa];
                idxa++;
            }
        }
        rez = max(rez, min(suma-i, sumb-i));
    }
    cout << fixed << setprecision(4) << rez << endl;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 380 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 2 ms 364 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 380 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Correct 1 ms 364 KB Output is correct
10 Correct 1 ms 364 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 1 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 2 ms 364 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 83 ms 3308 KB Output is correct
18 Correct 83 ms 3308 KB Output is correct
19 Correct 91 ms 3308 KB Output is correct
20 Correct 85 ms 3308 KB Output is correct
21 Correct 92 ms 3820 KB Output is correct
22 Correct 89 ms 3308 KB Output is correct
23 Correct 84 ms 3268 KB Output is correct
24 Correct 83 ms 3308 KB Output is correct
25 Correct 88 ms 3308 KB Output is correct
26 Correct 92 ms 3768 KB Output is correct