Submission #988366

# Submission time Handle Problem Language Result Execution time Memory
988366 2024-05-24T14:42:01 Z parlimoos Sure Bet (CEOI17_sure) C++14
0 / 100
1 ms 348 KB
//Be Name KHODA
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
#define pb push_back
#define pp pop_back
#define lb lower_bound
#define ub upper_bound
#define cl clear
#define bg begin
#define arr(x) array<int , x>
#define all(x) array<ll , x>
#define endl '\n'

int n;
vector<ll> a[2];

bool jg(ll e){
    bool flg = (e == 0);
    for(ll i = 1 ; i <= n + n ; i++){
        auto itr = lb(a[0].bg() , a[0].end() , e + (i * 10000));
        if(itr == a[0].end()) continue;
        int inx = i - int(itr - a[0].bg()) - 1;
        if(inx > n or inx <= 0) continue;
        if(a[1][inx - 1] >= e + (i * 10000)) flg = 1;
    }
    return flg;
}
ll bs(){
    ll l = 0 , r = (1ll * 1e18);
    while(r - l - 1 > 1){
        ll c = l + (r - l - 1) / 2 + 1;
        if(jg(c)) l = c - 1;
        else r = c;
    }
    if(r - l - 1 == 1 and jg(l + 1)) return l + 1;
    return l;
}

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

    cin >> n;
    for(int i = 0 ; i < n ; i++){
        double d1 , d2;
        cin >> d1 >> d2;
        d1 *= 10000 , d2 *= 10000;
        a[0].pb(d1) , a[1].pb(d2);
    }
    sort(a[0].bg() , a[0].end() , [](ll a , ll b){
        return (a > b);
    });
    sort(a[1].bg() , a[1].end() , [](ll a , ll b){
        return (a > b);
    });
    for(int i = 1 ; i < n ; i++) a[0][i] += a[0][i - 1] , a[1][i] += a[1][i - 1];
    double o = bs() / double(10000);
    cout << o;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -