Submission #987408

# Submission time Handle Problem Language Result Execution time Memory
987408 2024-05-22T17:33:21 Z ErJ Sure Bet (CEOI17_sure) C++17
0 / 100
1 ms 348 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(ia >= 0 && ib >= 0){
        if(a > b){
            pocet++;
            b += B[ib];
            ib--;
        }else{
            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 344 KB Output is correct
2 Incorrect 1 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Incorrect 1 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Incorrect 1 ms 348 KB Output isn't correct
3 Halted 0 ms 0 KB -