Submission #64664

#TimeUsernameProblemLanguageResultExecution timeMemory
64664alenam0161Rice Hub (IOI11_ricehub)C++17
68 / 100
35 ms8840 KiB
#include "ricehub.h" #include <bits/stdc++.h> using namespace std; int besthub(int R, int L, int X[], long long B) { int l=1; int r=R; int ans=1; while(l<=r){ int mid=(l+r)/2; int curpos=0; int hwl=1; int hwr=mid-1; long long cur=0; int cl=0;int cr=mid-1; for(int i=1;i<mid;++i){ cur+=X[i]-X[0]; } // cout<<mid<<" "<<cur<<endl; if(cur<=B){ ans=mid; l=mid+1; continue; } // cout<<"h"<<endl; bool ok=true; while(cr<R){ while(hwl<hwr&&curpos<cr){ cur-=(hwr-hwl)*(X[curpos+1]-X[curpos]); hwl++;hwr--; curpos++; } // cout<<cur<<" "<<hwl<<" "<<hwr<<" "<<cl<<" "<<cr<<endl; if(cur<=B){ ok=false; break; } cl++;cr++; hwl--;hwr++; cur-=X[curpos]-X[cl-1]; cur+=X[cr]-X[curpos]; } if(ok){ r=mid-1; } else{ ans=mid; l=mid+1; } } return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...