제출 #328294

#제출 시각아이디문제언어결과실행 시간메모리
328294arnold518커다란 상품 (IOI17_prize)C++14
20 / 100
81 ms2028 KiB
#include "prize.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; const int MAXN = 2e5; int N; pii M[MAXN+10]; pii query(int x) { if(M[x]!=pii(-1, -1)) return M[x]; vector<int> res=ask(x-1); return M[x]=pii(res[0], res[1]); } int find_best(int _N) { N=_N; for(int i=1; i<=N; i++) M[i]=pii(-1, -1); int t=0; for(int i=1; i<=min(460, N); i++) { pii p=query(i); t=max(t, p.first+p.second); } for(int i=1; i<=N;) { pii p=query(i); if(p.first==0 && p.second==0) return i-1; if(p.first+p.second==t) { int lo=i, hi=N+1; while(lo+1<hi) { int mid=lo+hi>>1; if(query(mid).second==p.second) lo=mid; else hi=mid; } i=hi; } else { i++; } } }

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

prize.cpp: In function 'int find_best(int)':
prize.cpp:42:15: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   42 |     int mid=lo+hi>>1;
      |             ~~^~~
prize.cpp:53:1: warning: control reaches end of non-void function [-Wreturn-type]
   53 | }
      | ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...