Submission #1003216

#TimeUsernameProblemLanguageResultExecution timeMemory
1003216HasanV11010238Rice Hub (IOI11_ricehub)C++17
68 / 100
1087 ms3456 KiB
#include "ricehub.h" #include <bits/stdc++.h> #define ll long long #define INF 1000000000000 using namespace std; vector<ll> pr, x; int besthub(int R, int L, int X[], long long B) { pr.assign(R + 1, 0), x.assign(R + 1, 0); for (int i = 1; i <= R; i++){ x[i] = X[i - 1]; pr[i] = pr[i - 1] + x[i]; } ll ans = 0; for (int i = 1; i <= R; i++){ ll co = 0; ll l = i, r = i; while (true){ ll col, cor; if (l == 1){ col = INF; } else{ col = x[i] - x[l - 1]; } if (r == R){ cor = INF; } else{ cor = x[r + 1] - x[i]; } if (co + min(col, cor) > B){ break; } else if (col < cor){ co += col; l--; } else{ co += cor; r++; } } ans = max(ans, r - l + 1); } 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...