제출 #828684

#제출 시각아이디문제언어결과실행 시간메모리
828684gromperen커다란 상품 (IOI17_prize)C++14
0 / 100
17 ms12040 KiB
#include "prize.h" #include <bits/stdc++.h> using namespace std; const int MAXN = 2e5+5; vector<int> p; vector<vector<int>> memo(MAXN, vector<int>(2, -1)); vector<int> _ask(int i) { if (memo[i][0] != -1) return memo[i]; return memo[i] = ask(p[i]); } int find_best(int n) { int mx = 0; int sqrtn = sqrt(n); p.resize(n); for (int i = 0; i < n; ++i) { p[i] = i; } srand(420); random_shuffle(p.begin(), p.end()); int k = 0; for(int i = 0; i < sqrtn; i++) { vector<int> res = _ask(i); if(res[0] + res[1] == 0) return i; mx = max(mx, res[0] + res[1]); } for (int i = sqrtn; i < n; ++i) { auto res = _ask(i); if (res[0] + res[1] < mx) { if (res[0] + res[1] == 0) return i; continue; } int l = i, r = n-1; int tmp = i; while(l<r) { int mid = (l+r)/2; auto rmid = _ask(mid); if (rmid[0]+rmid[1] < mx || rmid[1] < res[1]) { if (rmid[0]+rmid[1] == 0) return mid; r = mid; } else { l = mid+1; tmp = mid; } } i = tmp; } return 0; }

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

prize.cpp: In function 'int find_best(int)':
prize.cpp:23:6: warning: unused variable 'k' [-Wunused-variable]
   23 |  int k = 0;
      |      ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...