# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1128135 | micro7 | Rabbit Carrot (LMIO19_triusis) | C++17 | 1093 ms | 2196 KiB |
#include <algorithm>
#include <cstdio>
#include <functional>
#include <map>
using namespace std;
constexpr int MAXN = 2e5;
int n, m, a[MAXN + 1];
int dp[MAXN + 1];
map<int, int, greater<>> s;
int main() {
scanf("%d%d", &n, &m);
for (int i = 1; i <= n; ++i) {
scanf("%d", &a[i]);
}
s[0] = 0;
for (int i = 1; i <= n; ++i) {
dp[i] = -1;
for (auto [val, j] : s) {
if (a[i] - i * m > val) {
break;
}
if (dp[j] != -1) {
dp[i] = max(dp[i], dp[j] + 1);
}
}
s[a[i] - i * m] = i;
}
printf("%d", n - *max_element(dp, dp + n + 1));
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |