제출 #397618

#제출 시각아이디문제언어결과실행 시간메모리
397618rocks03커다란 상품 (IOI17_prize)C++14
20 / 100
116 ms328 KiB
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define ff first
#define ss second
#define pb push_back
#define SZ(x) ((int)(x).size())
#define all(x) x.begin(), x.end()
#define debug(x) cout << #x << ": " << x << " "
#define nl cout << "\n"
#define rep(i, a, b) for(int i = (a); i < (b); i++)
#define per(i, a, b) for(int i = (a); i >= (b); i--)
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

vector<int> ask(int i);

int cerca(int x, int ql, int qr){
    assert(ql <= qr);
    int l = ql, r = qr + 1;
    while(r - l > 1){
        int m = (l + r) / 2;
        vector<int> res = ask(m);
        res[0] -= x;
        if(res[0] < 0){
            l = m; break;
        } else if(res[0] == 0) l = m;
        else r = m;
    }
    vector<int> res = ask(l);
    if(res[0] == 0 && res[1] == 0){
        return l;
    }
    return cerca(res[0], l + 1, qr);
}

int find_best(int N){
    return cerca(0, 0, N - 1);
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...