Submission #848853

#TimeUsernameProblemLanguageResultExecution timeMemory
848853Mr_PhRice Hub (IOI11_ricehub)C++14
68 / 100
10 ms3936 KiB
#include "ricehub.h" //#include "grader.cpp" #include <bits/stdc++.h> #define ll long long #define sz size() using namespace std; int besthub(int r, int l, int arr[], long long b) { int p1=0,p2=0; vector<int>prf(r); prf[0]=arr[0]; for(int i=1;i<r;i++) prf[i]=prf[i-1]+arr[i]; int ans=0,ans1=0; while(p1<r) { while(p2<r) { int idx=(p1+p2)/2; int left=(idx==0?0:prf[idx-1]),right=prf[p2]-prf[idx]; if(p1!=0)left-=prf[p1-1]; int val=arr[idx]; //int test=left; left=val*(idx-p1)-left; right-=val*(p2-idx); if(right+left<=b){ // cout<<p1<<" "<<p2<<" "<<left<<" "<<right<<endl; ans=max(ans,(p2-p1+1)); p2++; } else break; } p1++; } return ans; }

Compilation message (stderr)

ricehub.cpp: In function 'int besthub(int, int, int*, long long int)':
ricehub.cpp:14:15: warning: unused variable 'ans1' [-Wunused-variable]
   14 |     int ans=0,ans1=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...