Submission #402479

#TimeUsernameProblemLanguageResultExecution timeMemory
402479Jasiekstrz쌀 창고 (IOI11_ricehub)C++17
100 / 100
16 ms2512 KiB
#include<bits/stdc++.h> #include "ricehub.h" #define fi first #define se second using namespace std; const int NN=1e5; long long t[NN+10]; void move_med(int l,int r,int &m,long long &w) { if(m==(l+r)/2) return; w+=(t[m+1]-t[m])*(m-l+1); w-=(t[m+1]-t[m])*(r-m); m++; return; } int besthub(int R,int L,int X[],long long B) { for(int i=0;i<R;i++) t[i]=X[i]; int ans=0; int l=0,r=0,m=0; long long w=0; while(l<R) { if(w>B) { w-=X[m]-X[l]; l++; move_med(l,r,m,w); } else { ans=max(ans,r-l+1); r++; if(r>=R) break; w+=X[r]-X[m]; move_med(l,r,m,w); } } 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...