Submission #1128284

#TimeUsernameProblemLanguageResultExecution timeMemory
1128284knot222Rice Hub (IOI11_ricehub)C++20
100 / 100
12 ms2388 KiB
#include "ricehub.h" #include<bits/stdc++.h> #define ll long long int using namespace std; const int N=100005; int n; ll x[N]; ll qs[N]; ll bbb; int check(int F) { for (int l=1,r=F;r<=n;l++,r++) { int m=(l+r)/2; if (((F-1)/2)*x[m]-qs[m-1]+qs[l-1]+qs[r]-qs[m]-(F/2)*x[m]<=bbb) { return 1; } } return 0; } int besthub(int R, int L, int X[], long long B){ bbb=B; n = R; qs[0] = 0; for (int i=0;i<R;i++) { x[i+1] = X[i]; qs[i+1] = qs[i]+X[i]; } int l=0; int r=INT_MAX/2; while (l<r) { int mid = (l+r+1)/2; if (check(mid)) { l=mid; } else { r=mid-1; } } return l; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...