제출 #797300

#제출 시각아이디문제언어결과실행 시간메모리
797300firewater커다란 상품 (IOI17_prize)C++14
0 / 100
1300 ms1084 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,p[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) { int now=0; if(!p[now])x--; while(x){ now++; while(p[now])now++; 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) p[i]=0; m=n; while(1){ l=1;r=m; while(l<r){ mid=l+r>>1; x=find(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; } if(s[0]+s[1]==0)return find(l); p[l]=1; T.add(1); } }

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

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