Submission #343167

# Submission time Handle Problem Language Result Execution time Memory
343167 2021-01-03T13:11:57 Z benedict0724 Sure Bet (CEOI17_sure) C++17
60 / 100
2 ms 492 KB
#include <bits/stdc++.h>

using namespace std;

double a[1002];
double b[1002];

double sum_a[1002];
double sum_b[1002];

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 0 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 0 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 0 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 0 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 0 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 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 1 ms 364 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 0 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 0 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 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 1 ms 364 KB Output is correct
16 Correct 1 ms 364 KB Output is correct
17 Runtime error 2 ms 492 KB Execution killed with signal 11 (could be triggered by violating memory limits)
18 Halted 0 ms 0 KB -