답안 #988372

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
988372 2024-05-24T14:45:48 Z parlimoos Sure Bet (CEOI17_sure) C++14
0 / 100
1 ms 600 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];
    ll o = bs();
    cout << o / 10000 << ".";
    o %= 10000 , cout << o / 1000;
    o %= 1000 , cout << o / 100;
    o %= 100 , cout << o / 10;
    o %= 10 , cout << o;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 600 KB Output is correct
6 Incorrect 1 ms 348 KB Output isn't correct
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 600 KB Output is correct
6 Incorrect 1 ms 348 KB Output isn't correct
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 600 KB Output is correct
6 Incorrect 1 ms 348 KB Output isn't correct
7 Halted 0 ms 0 KB -