제출 #390479

#제출 시각아이디문제언어결과실행 시간메모리
390479alireza_kaviani커다란 상품 (IOI17_prize)C++11
97.11 / 100
69 ms1880 KiB
#include <bits/stdc++.h> #include "prize.h" using namespace std; typedef pair<int, int> pii; #define X first #define Y second const int MAXN = 2e5 + 10; int cnt , mx; pii res[MAXN]; pii get(int x){ if(res[x].X != -1) return res[x]; vector<int> vec = ask(x); res[x] = {vec[0] , vec[1]}; return res[x]; } int solve(int l , int r){ pii cur = get(r - 1); if(cur.X + cur.Y == mx && cur.X <= cnt) return -1; if(r - l == 1){ cnt++; if(cur.X + cur.Y == 0) return l; return -1; } int mid = l + r >> 1; int ans = solve(l , mid); if(ans == -1) return solve(mid , r); return ans; } int find_best(int n) { fill(res , res + MAXN , pii(-1 , -1)); for(int i = 0 ; i < min(530 , n) ; i++){ pii x = get(i); mx = max(mx , x.X + x.Y); } return solve(0 , n); }

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

prize.cpp: In function 'int solve(int, int)':
prize.cpp:30:14: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   30 |  int mid = l + r >> 1;
      |            ~~^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...