제출 #797309

#제출 시각아이디문제언어결과실행 시간메모리
797309firewater커다란 상품 (IOI17_prize)C++14
0 / 100
3083 ms1096 KiB
#include "prize.h" #include <vector> #include<cstdio> #include<cstring> #include<iostream> #include<algorithm> #define ll long long using namespace std; #define MX 202300 int n,m,l,r,mx,mid,x,nx[MX]; vector<int>s; struct Tree { int c[MX]; void add(int x) { x++; for(;x<=n;x+=x&-x) c[x]++; return; } int ask(int x) { x++; int sum=0; for(;x;x-=x&-x) sum+=c[x]; return sum; } }T; int find(int x) { return (nx[x]==x?x:nx[x]=find(nx[x])); } int get(int x) { int now=-1; while(x){ now=find(now+1); x--; } return now; } int find_best(int N) { n=N; mx=0; for(int i=0;i<min(500,n);++i){ s=ask(i); mx=max(mx,s[0]+s[1]); } for(int i=0;i<n;++i) nx[i]=i; m=n; while(1){ l=1;r=m; while(l<r){ mid=l+r>>1; x=get(mid); s=ask(x); if(s[0]+s[1]!=mx){ l=mid; break; } if(s[0]>T.ask(x))r=mid-1; else l=mid+1; } x=get(l); if(s[0]+s[1]==0)return x; nx[x]=nx[x+1]; T.add(x); } }

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

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