Submission #343170

# Submission time Handle Problem Language Result Execution time Memory
343170 2021-01-03T13:12:52 Z benedict0724 Sure Bet (CEOI17_sure) C++17
100 / 100
111 ms 3692 KB
#include <bits/stdc++.h>

using namespace std;

double a[100002];
double b[100002];

bool cmp(double x, double y){
    return x > y;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin >> n;
    for(int i=1;i<=n;i++){
        cin >> a[i] >> b[i];
    }
    sort(a+1, a+n+1, cmp);
    sort(b+1, b+n+1, cmp);

    double profit_a = 0, profit_b = 0, ans = 0;

    for(int x = 0, y = 0; x + y < 2*n ;){
        if(x == n){
            y++;
            profit_a += -1;
            profit_b += b[y] - 1;
            ans = max(ans, min(profit_a, profit_b));
            continue;
        }
        if(y == n){
            x++;
            profit_a += a[x] - 1;
            profit_b += -1;
            ans = max(ans, min(profit_a, profit_b));
            continue;
        }

        if(profit_a > profit_b){
            y++;
            profit_a += -1;
            profit_b += b[y] - 1;
            ans = max(ans, min(profit_a, profit_b));
        }

        else{
            x++;
            profit_a += a[x] - 1;
            profit_b += -1;
            ans = max(ans, min(profit_a, profit_b));
        }
    }

    printf("%.4lf", ans);
}
# 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 364 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 512 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 2 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 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 364 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 512 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 1 ms 364 KB Output is correct
13 Correct 2 ms 364 KB Output is correct
14 Correct 1 ms 364 KB Output is correct
15 Correct 1 ms 364 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Correct 103 ms 3180 KB Output is correct
18 Correct 92 ms 3308 KB Output is correct
19 Correct 105 ms 3308 KB Output is correct
20 Correct 111 ms 3308 KB Output is correct
21 Correct 97 ms 3692 KB Output is correct
22 Correct 102 ms 3308 KB Output is correct
23 Correct 88 ms 3328 KB Output is correct
24 Correct 88 ms 3308 KB Output is correct
25 Correct 90 ms 3436 KB Output is correct
26 Correct 95 ms 3692 KB Output is correct