Submission #207781

#TimeUsernameProblemLanguageResultExecution timeMemory
207781peuchRice Hub (IOI11_ricehub)C++17
68 / 100
23 ms2296 KiB
#include "ricehub.h" #include<bits/stdc++.h> using namespace std; const int MAXN = 200000; long long sumD[MAXN], sumE[MAXN]; bool test(int ini, int fim, int R, long long B, int X[]); int besthub(int R, int L, int X[], long long B) { int ans = 0; sumD[0] = X[0]; sumE[R - 1] = 0; for(int i = R - 2; i >= 0; i--) sumE[i] = sumE[i + 1] + X[R - 1] - X[i]; for(int i = 1; i < R; i++) sumD[i] = sumD[i - 1] + X[i]; for(int ini = 0, fim = 0; ini < R; ini++){ while(test(ini, fim, R, B, X) && fim < R) fim++; ans = max(fim - ini, ans); } return ans; } bool test(int ini, int fim, int R, long long B, int X[]){ int m = (ini + fim) >> 1; return (sumD[fim] - sumD[m] - (fim - m) * X[m]) + (sumE[ini] - sumE[m] - (m - ini) * (X[R - 1] - X[m])) <= B; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...