Submission #1164689

#TimeUsernameProblemLanguageResultExecution timeMemory
1164689SmuggingSpun커다란 상품 (IOI17_prize)C++20
0 / 100
1 ms1172 KiB
#include<bits/stdc++.h>
#include "prize.h"
using namespace std;
int find_best(int n) {
    vector<int>f(n, -1);
    auto id = [&] (int i){
        if(f[i] != -1){
            return f[i];
        }
        vector<int>cnt = ask(i);
        return f[i] = cnt[0] + cnt[1];
    };
    for(int i = 0; i < n; ){
        if(id(i) == 0){
            return i;
        }
        if(id(i) != id(i + 1)){
            i++;
        }
        else{
            int low = i + 2, high = n - 2, p = n - 1;
            while(low <= high){
                int mid = (low + high) >> 1;
                if(id(i) != id(mid)){
                    high = (p = mid) - 1;
                }
                else{
                    low = mid + 1;
                }
            }
            i = p;
        }
    }
}

Compilation message (stderr)

prize.cpp: In function 'int find_best(int)':
prize.cpp:34:1: warning: control reaches end of non-void function [-Wreturn-type]
   34 | }
      | ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...