Submission #936158

#TimeUsernameProblemLanguageResultExecution timeMemory
936158AtabayRajabliRice Hub (IOI11_ricehub)C++17
100 / 100
10 ms3676 KiB
#include "ricehub.h" #include <bits/stdc++.h> using namespace std; long long p[100005]; long long cost(int l, int r) { long long m = (l + r) >> 1; long long med = p[m] - p[m - 1]; return med * (m - l) - (p[m - 1] - p[l - 1]) + p[r] - p[m] - med * (r - m); } int besthub(int R, int L, int X[], long long B) { for(int i = 0; i < R; i++) { p[i + 1] = X[i] + p[i]; } int r = 1; int ans = 0; for(int l = 1; l <= R; l++) { while(r <= R && cost(l, r) <= B) { ans = max(ans, r - l + 1); r++; } } return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...