Submission #862038

#TimeUsernameProblemLanguageResultExecution timeMemory
862038culver0412Rice Hub (IOI11_ricehub)C++17
100 / 100
11 ms5212 KiB
#include "ricehub.h" #ifdef ONLINE_JUDGE #include <bits/stdc++.h> #else #include"bits/stdc++.h" #endif using namespace std; int besthub(int R, int L, int X[], long long B) { long long int arr[R+1],p[R+1]={0}; for(int i=1;i<=R;i++){ arr[i]=X[i-1]; p[i]=p[i-1]+arr[i]; } int ptr1=1,ptr2=1,ans=1; while(ptr2<=R){ if(ptr1==ptr2){ ptr2++; } int m1=(ptr1+ptr2)/2,m2=m1+(ptr1+ptr2)%2; long long int td=(p[ptr2]-p[m2-1])-(p[m1]-p[ptr1-1]); if(td<=B){ ans=max(ans,ptr2-ptr1+1); ptr2++; } else{ ptr1++; } } 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...