제출 #371463

#제출 시각아이디문제언어결과실행 시간메모리
371463urd05커다란 상품 (IOI17_prize)C++14
0 / 100
3033 ms1132 KiB
#include "prize.h"
#include <bits/stdc++.h>
using namespace std;

int save[200000];
int ret;

int f(int i) {
    if (save[i]!=-1) {
        return save[i];
    }
    vector<int> v=ask(i);
    if (v[0]==0&&v[1]==0) {
        ret=i;
    }
    return save[i]=v[1];
}

int find_best(int n) {
    ret=-1;
    int now=0;
    memset(save,-1,sizeof(save));
    if (f(now)==0) {
        return now;
    }
    while (1) {
        int lo=now; //f(lo)!=0
        int hi=n;
        while (lo+1<hi) {
            int mid=(lo+hi)/2;
            if (f(mid)!=0) {
                hi=mid;
            }
            else {
                lo=mid;
            }
            if (ret!=-1) {
                return ret;
            }
        }
        now=lo;
    }
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...