Submission #248987

# Submission time Handle Problem Language Result Execution time Memory
248987 2020-07-13T21:25:32 Z Sorting Sure Bet (CEOI17_sure) C++14
100 / 100
110 ms 3704 KB
#include <bits/stdc++.h>

using namespace std;

const int k_N = 1e5 + 3;

double a[k_N], b[k_N];

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

    int n;
    cin >> n;

    for(int i = 0; i < n; ++i)
        cin >> a[i] >> b[i];

    sort(a, a + n, greater<double>());
    sort(b, b + n, greater<double>());

    double curr_a = 0, curr_b = 0, answer = 0;
    int i = 0, j = 0;
    while(i != n && j != n){
        if(curr_a < curr_b)
            curr_a += a[i], i++;
        else
            curr_b += b[j], j++;
        answer = max(min(curr_a, curr_b) - i - j, answer);
    }

    while(i != n){
        curr_a += a[i], i++;
        answer = max(min(curr_a, curr_b) - i - j, answer);
    }

    while(j != n){
        curr_b += b[j], j++;
        answer = max(min(curr_a, curr_b) - i - j, answer);
    }

    cout << fixed << setprecision(4) << answer << "\n";
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 0 ms 384 KB Output is correct
6 Correct 1 ms 392 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 0 ms 384 KB Output is correct
6 Correct 1 ms 392 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 0 ms 384 KB Output is correct
9 Correct 0 ms 384 KB Output is correct
10 Correct 0 ms 384 KB Output is correct
11 Correct 0 ms 384 KB Output is correct
12 Correct 1 ms 384 KB Output is correct
13 Correct 1 ms 384 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 1 ms 384 KB Output is correct
16 Correct 1 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 384 KB Output is correct
2 Correct 0 ms 384 KB Output is correct
3 Correct 0 ms 384 KB Output is correct
4 Correct 0 ms 384 KB Output is correct
5 Correct 0 ms 384 KB Output is correct
6 Correct 1 ms 392 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 0 ms 384 KB Output is correct
9 Correct 0 ms 384 KB Output is correct
10 Correct 0 ms 384 KB Output is correct
11 Correct 0 ms 384 KB Output is correct
12 Correct 1 ms 384 KB Output is correct
13 Correct 1 ms 384 KB Output is correct
14 Correct 1 ms 384 KB Output is correct
15 Correct 1 ms 384 KB Output is correct
16 Correct 1 ms 384 KB Output is correct
17 Correct 92 ms 3208 KB Output is correct
18 Correct 94 ms 3320 KB Output is correct
19 Correct 99 ms 3320 KB Output is correct
20 Correct 95 ms 3404 KB Output is correct
21 Correct 110 ms 3576 KB Output is correct
22 Correct 91 ms 3320 KB Output is correct
23 Correct 93 ms 3320 KB Output is correct
24 Correct 101 ms 3320 KB Output is correct
25 Correct 93 ms 3320 KB Output is correct
26 Correct 105 ms 3704 KB Output is correct