Submission #1032623

#TimeUsernameProblemLanguageResultExecution timeMemory
1032623ezzzayRice Hub (IOI11_ricehub)C++14
0 / 100
3 ms612 KiB
#include "ricehub.h" #include<bits/stdc++.h> using namespace std; #define ff first #define ss second #define pb push_back #define ll long long int besthub(int R, int L, int X[], long long B) { int n=R; int ans=0; for(int i=0;i<n;i++){ int l=-1,r=i+1; ll k=B; int cnt=0; while(1){ if(l==-1 and r==n)break; if(l==-1){ if(abs(X[r]-X[i])<=k){ cnt++; k-=abs(X[r]-X[i]); r++; } else{break;} } else if(r==n){ if(abs(X[l]-X[i])<=k){ cnt++; k-=abs(X[l]-X[i]); l--; } else{break;} } else{ ll a=abs(X[r]-X[i]),b=abs(X[l]-X[i]); if(a<=b){ if(abs(X[r]-X[i])<=k){ cnt++; k-=abs(X[r]-X[i]); r++; } else{break;} } else{ if(abs(X[l]-X[i])<=k){ cnt++; k-=abs(X[l]-X[i]); l--; } else{break;} } } } ans=max(ans,cnt); } return ans+1; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...