Submission #1164704

#TimeUsernameProblemLanguageResultExecution timeMemory
1164704SmuggingSpun커다란 상품 (IOI17_prize)C++20
90 / 100
31 ms11364 KiB
#include<bits/stdc++.h>
#include "prize.h"
using namespace std;
const int SIZE = 470;
int find_best(int n) {
    vector<vector<int>>cnt(n, vector<int>(2, -1));
    auto id = [&] (int i){
        if(cnt[i][0] != -1){
            return cnt[i];
        }
        return cnt[i] = ask(i);
    };
    for(int i = 0; i + 1 < n; ){
        if(id(i)[0] == 0 && id(i)[1] == 0){
            return i;
        }
        while(true){
            int j = min(n - 1, i + SIZE);
            if(id(i) == id(j)){
                i = j;
            }
            else{
                int low = i + 2, high = j - 1;
                while(low <= high){
                    int mid = (low + high) >> 1;
                    if(id(i) != id(mid)){
                        high = (j = mid) - 1;
                    }
                    else{
                        low = mid + 1;
                    }
                }
                i = j;
                break;
            }
        }
    }
    return n - 1;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...