Submission #95096

#TimeUsernameProblemLanguageResultExecution timeMemory
95096Alexa2001Rice Hub (IOI11_ricehub)C++17
100 / 100
17 ms3420 KiB
#include "ricehub.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; const int Nmax = 1e5 + 5; ll x[Nmax], s[Nmax], lim; int n; bool check(int nr) { int i, m; ll curr; for(i=0; i<=n-nr; ++i) { m = (i + i + nr - 1) / 2; curr = (m - i + 1) * x[m] - (s[m] - s[i-1]); curr += (s[i+nr-1] - s[m]) - (i+nr-1 - m) * x[m]; if(curr <= lim) return 1; } return 0; } int besthub(int R, int L, int X[], ll B) { int st = 0, dr = R, mid, i; n = R; lim = B; for(i=0; i<n; ++i) x[i] = X[i], s[i] = s[i-1] + x[i]; while(st <= dr) { mid = (st + dr) / 2; if(check(mid)) st = mid+1; else dr = mid-1; } return dr; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...