Submission #987410

# Submission time Handle Problem Language Result Execution time Memory
987410 2024-05-22T17:37:27 Z ErJ Sure Bet (CEOI17_sure) C++17
100 / 100
118 ms 3664 KB
#include <bits/stdc++.h>

#define ll long long
#define rep(i,n) for(int i = 0; i < n; i++)
#define vi vector<ll>
#define vvi vector<vi>
#define pp pair<ll,ll>
#define vp vector<pp>
#define vvp vector<vp>
#define inf 1000000000000000000
#define mod 1000000007

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<double> A(n), B(n);
    rep(i,n){
        cin >> A[i] >> B[i];
    }
    sort(A.begin(), A.end());
    sort(B.begin(), B.end());
    int pocet = 0;
    double a = 0, b = 0;
    int ia = n - 1;
    int ib = n-1;
    double ans = 0;
    while(true){    
        if(a > b){
            if(ib < 0) break;
            pocet++;
            b += B[ib];
            ib--;
        }else{
            if(ia < 0) break;
            pocet++;
            a += A[ia];
            ia--;
        }
        ans = max(ans, min(a - pocet, b - pocet));
    }
    printf("%.4lf",(double)ans);
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 856 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 856 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 432 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 2 ms 348 KB Output is correct
13 Correct 2 ms 344 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 2 ms 348 KB Output is correct
16 Correct 2 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 856 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 432 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 2 ms 348 KB Output is correct
13 Correct 2 ms 344 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 2 ms 348 KB Output is correct
16 Correct 2 ms 348 KB Output is correct
17 Correct 94 ms 3120 KB Output is correct
18 Correct 95 ms 3124 KB Output is correct
19 Correct 100 ms 3360 KB Output is correct
20 Correct 94 ms 3156 KB Output is correct
21 Correct 104 ms 3524 KB Output is correct
22 Correct 96 ms 3132 KB Output is correct
23 Correct 111 ms 3152 KB Output is correct
24 Correct 114 ms 3132 KB Output is correct
25 Correct 94 ms 3156 KB Output is correct
26 Correct 118 ms 3664 KB Output is correct