Submission #743221

#TimeUsernameProblemLanguageResultExecution timeMemory
743221Sainen420Rice Hub (IOI11_ricehub)C++17
17 / 100
1050 ms1112 KiB
#include "ricehub.h" #include <bits/stdc++.h> using namespace std; using pi = pair<int,int>; int besthub(int R, int L, int X[], long long B) { int ans=0,mi,cnt=0,l,r; long long int b = B; for(int i=0;i<R;i++){ b=B; l=i;r=i; cnt=1; //EXPAND while(b>0){ mi=2e9; //cout << r << ' ' << l << endl; if(l>=1){ mi=min(abs(X[l-1]-X[i]),mi); } if(r<(L-1)){ mi=min(mi,abs(X[r+1]-X[i])); } if(mi==2e9)break; if(b-mi < 0)break; else{ cnt++; b-=mi; if(l>=1 && mi==abs(X[l-1]-X[i])){ l--; }else{ r++; } } } ans=max(cnt,ans); } 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...