Submission #978437

#TimeUsernameProblemLanguageResultExecution timeMemory
978437NewtonabcRice Hub (IOI11_ricehub)C++14
100 / 100
18 ms4464 KiB
#include "ricehub.h" #include<bits/stdc++.h> using namespace std; int besthub(int R, int L, int X[], long long B) { const int N=1e5+10; long long qs[N]; double tX[N]; int mx=0; qs[0]=X[0]; tX[0]=X[0]; for(int i=1;i<R;i++) qs[i]=X[i]+qs[i-1],tX[i]=X[i]; for(int i=0;i<R;i++){ int l=i,r=R-1; while(l<r){ int mid=(l+r+1)/2; long long sum=qs[mid],bg=0; if(i>0) sum-=qs[i-1]; double mean=(double)sum/(double)(mid-i+1); int ind=(i+mid)/2; bg=(qs[mid]-qs[ind]-((long long)X[ind]*(long long)(mid-ind)))+((long long)X[ind]*(long long)(ind-i)); if(ind-1>=0) bg-=qs[ind-1]; if(i>0) bg+=qs[i-1]; if(bg<=B) l=mid; else r=mid-1; } mx=max(mx,l-i+1); } return mx; }

Compilation message (stderr)

ricehub.cpp: In function 'int besthub(int, int, int*, long long int)':
ricehub.cpp:19:11: warning: unused variable 'mean' [-Wunused-variable]
   19 |    double mean=(double)sum/(double)(mid-i+1);
      |           ^~~~
ricehub.cpp:8:9: warning: variable 'tX' set but not used [-Wunused-but-set-variable]
    8 |  double tX[N];
      |         ^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...