Submission #316147

#TimeUsernameProblemLanguageResultExecution timeMemory
316147nikatamlianiThe Big Prize (IOI17_prize)C++14
0 / 100
72 ms384 KiB
#include <bits/stdc++.h> using namespace std; #include "prize.h" // int prize[] = {3, 2, 3, 1, 3, 3, 2, 3}; // int n = 8; // vector < int > ask(int x) { // int prefix = 0, suffix = 0; // for(int i = 0; i < x; ++i) { // if(prize[i] < prize[x]) ++prefix; // } // for(int i = x + 1; i < n; ++i) { // if(prize[i] < prize[x]) ++suffix; // } // return {prefix, suffix}; // } int find_best(int n) { int next = -1; for(int i = 0; i < n; i = next) { int l = i, r = n - 1; next = -1; vector < int > t = ask(i); while(r >= l) { int m = l + r >> 1; vector < int > x = ask(m); if(x == t) { next = m; l = m + 1; } else { r = m - 1; } } assert(next >= 0); vector < int > tt = ask(next); for(int j = next + 1; j < n; ++j) { vector < int > p = ask(j); if(p[0] == 0 && p[1] == 0) return j; if(p[0] > t[0] && t[1] == p[1] + j - next - 1) { next = j; break; } } } //this is bad for(int i = 0; i < n; ++i) { vector < int > p = ask(i); if(!p[0] && !p[1]) return i; } } // int main() { // cout << find_best(8) << '\n'; // }

Compilation message (stderr)

prize.cpp: In function 'int find_best(int)':
prize.cpp:22:23: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   22 |             int m = l + r >> 1;
      |                     ~~^~~
prize.cpp:47:1: warning: control reaches end of non-void function [-Wreturn-type]
   47 | }
      | ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...