제출 #73989

#제출 시각아이디문제언어결과실행 시간메모리
73989renatsj커다란 상품 (IOI17_prize)C++14
90 / 100
119 ms2112 KiB
#include<bits/stdc++.h> #include "prize.h" using namespace std; int i,j,nn,m,l,r,c,xl,xr,maz,rez,mas[200005][2]; vector<int> xx; vector<int> aask(int h) { if (mas[h][0]==-1&&mas[h][1]==-1) { xx=ask(nn-1-h); mas[h][0]=xx[1]; mas[h][1]=xx[0]; } xx[0]=mas[h][0]; xx[1]=mas[h][1]; return xx; } int find_best(int n) { nn=n; i=0; while (i<n-1) { mas[i][0]=-1; mas[i][1]=-1; i++; } l=0; r=n-1; rez=0; maz=0; while (true) { while (l<r) { c=l+(r-l)/2; xx=aask(c); xl=xx[0]; xr=xx[1]; if (xl+xr==0) { return n-1-c; } if (xl+xr>maz) { l=0; r=n-1; rez=0; maz=xl+xr; } else if (xl+xr<maz) { r=c; } else if (xl>rez) { r=c-1; } else { l=c+1; } } if (l<=n-1) { xx=aask(l); xl=xx[0]; xr=xx[1]; } if (xl+xr==0) { return n-1-l; } rez++; l++; if (l<=n-1) { xx=(aask(l)); xl=xx[0]; xr=xx[1]; if (xl+xr==0) { return n-1-l; } } while (xl+xr<maz&&l<n-1) { l++; rez++; xx=(aask(l)); xl=xx[0]; xr=xx[1]; if (xl+xr==0) { return n-1-l; } } if (xl+xr>maz) { maz=xl+xr; l=0; r=n-1; rez=0; } r=n-1; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...