제출 #316194

#제출 시각아이디문제언어결과실행 시간메모리
316194nikatamliani커다란 상품 (IOI17_prize)C++14
20 / 100
88 ms5496 KiB
#include <bits/stdc++.h> using namespace std; #include "prize.h" vector < vector < int > > memo; vector < int > memo_ask(int x) { if(!memo[x].empty()) return memo[x]; return memo[x] = ask(x); } int find_best(int n) { const int BLOCK_SIZE = 50; int next = -1, at_most = min(500, n - 1); vector < int > bad(2); memo.resize(n); for(int i = 0; i <= at_most; ++i) { vector < int > cur = memo_ask(i); if(bad[0] + bad[1] < cur[0] + cur[1]) bad = cur; } for(int i = 0; i < n; i = next + 1) { int l = i, r = n - 1; next = -1; vector < int > t = memo_ask(i); if(t[0] + t[1] != bad[0] + bad[1]) { next = i; if(t[0] == 0 && t[1] == 0) return i; continue; } vector < int > check = memo_ask(min(n - 1, i + BLOCK_SIZE)); if(check == t) { next = i + BLOCK_SIZE; continue; } while(r >= l) { int m = l + r >> 1; vector < int > x = memo_ask(m); if(x == t) { next = m; l = m + 1; } else { r = m - 1; } } assert(next >= i); } }

컴파일 시 표준 에러 (stderr) 메시지

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