Submission #668675

#TimeUsernameProblemLanguageResultExecution timeMemory
668675FEDIKUSRice Hub (IOI11_ricehub)C++17
100 / 100
16 ms1716 KiB
#include "ricehub.h" #include<algorithm> using namespace std; int besthub(int r, int l, int x[], long long b){ int duz=0; long long cena=0; int res=0; for(int i=0;i<r;i++){ while(i-duz-1>=0 && i+duz+1<r){ if(cena+abs(x[i]-x[i-duz-1])+abs(x[i]-x[i+duz+1])>b) break; cena+=abs(x[i]-x[i-duz-1])+abs(x[i]-x[i+duz+1]); duz++; } res=max(res,2*duz+1); if(i-duz-1>=0){ if(cena+abs(x[i]-x[i-duz-1])<=b) res=max(res,2*duz+2); } if(i+duz+1<r){ if(cena+abs(x[i]-x[i+duz+1])<=b) res=max(res,2*duz+2); } if(i<r-1 && duz>0){ cena+=x[i+1]-x[i]; cena-=abs(x[i+1]-x[i-duz]); cena-=abs(x[i+1]-x[i-duz+1]); duz--; } } return res; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...