Submission #170424

#TimeUsernameProblemLanguageResultExecution timeMemory
170424nafis_shifat쌀 창고 (IOI11_ricehub)C++14
0 / 100
8 ms888 KiB
#include "ricehub.h" #include<bits/stdc++.h> #define ll long long using namespace std; const int mxn=1e5+5; const ll inf=2e15+5; ll ar[mxn]; int besthub(int R, int L, int X[], long long B) { ll tot[mxn]; tot[0]=0; for(int i=1;i<=R;i++) { ar[i]=X[i-1]; tot[i]=tot[i-1]+ar[i]; } int ans=0; for(int i=1;i<=R;i++) { int lo=i; int hi=R; while(lo<=hi) { int mid=lo+hi>>1; int k=mid-i; ll ts=(tot[mid]-tot[i])-(ar[i]*k); ll t2=inf; int ind=max(1,i-k-1); int r=0; for(int j=0;j<3 && ind+j<i;j++) { ll tmp=ar[i]*(i-ind-j)-tot[i-1]-tot[ind+j-1]; if(tmp+ts<=B) { r=i-ind-j; t2=tmp; break; } } if(ts+t2<=B) { ans=max(ans,k+r+1); lo=mid+1; } else { hi=mid-1; } } } return ans; }

Compilation message (stderr)

ricehub.cpp: In function 'int besthub(int, int, int*, long long int)':
ricehub.cpp:31:14: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
    int mid=lo+hi>>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...