Submission #62983

#TimeUsernameProblemLanguageResultExecution timeMemory
62983zetapiRice Hub (IOI11_ricehub)C++14
68 / 100
1063 ms3396 KiB
#include "ricehub.h" #include <bits/stdc++.h> using namespace std; #define pb push_back #define mp make_pair #define ll long long #define itr ::iterator typedef pair<int,int> pii; const int MAX=1e5; int N,arr[MAX]; int cal(int ind,ll left) { int pre=ind-1,nxt=ind,res=0; while(left>=0 and (pre>=0 or nxt<N)) { if(pre<0 or (nxt<N and arr[ind]-arr[pre]>arr[nxt]-arr[ind])) { if(arr[nxt]-arr[ind]>left) break; left-=arr[nxt]-arr[ind]; res++; nxt++; } else { if(arr[ind]-arr[pre]>left) break; left-=arr[ind]-arr[pre]; res++; pre--; } } return res; } int besthub(int R, int L, int X[], long long B) { int res=0; N=R; for(int A=0;A<N;A++) arr[A]=X[A]; for(int A=0;A<N;A++) res=max(res,cal(A,B)); return res; } /*signed main() { ios_base::sync_with_stdio(false); int X[]={1,2,10,12,14}; cout<<besthub(5,20,X,6); return 0; }*/
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...