Submission #207782

#TimeUsernameProblemLanguageResultExecution timeMemory
207782peuchRice Hub (IOI11_ricehub)C++17
100 / 100
24 ms2296 KiB
#include "ricehub.h" #include<bits/stdc++.h> using namespace std; const int MAXN = 2000000; long long sumD[MAXN], sumE[MAXN]; bool test(long long ini, long long fim, int R, long long B, int X[]); int besthub(int R, int L, int X[], long long B) { long long 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(long long ini = 0, fim = 0; ini < R; ini++){ while(test(ini, fim, R, B, X) && fim < R) fim++; ans = max(fim - ini, ans); } return (int)ans; } bool test(long long ini, long long fim, int R, long long B, int X[]){ long long m = (ini + fim) >> 1; long long left = sumE[ini] - sumE[m] - (m - ini) * (X[R - 1] - X[m]); long long right = sumD[fim] - sumD[m] - (fim - m) * X[m]; return left + right <= 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...