# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1164782 | Ghulam_Junaid | Rabbit Carrot (LMIO19_triusis) | C++20 | 124 ms | 196232 KiB |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N = 5005;
ll n, m, ans, a[N], dp[N][N];
int main(){
cin >> n >> m;
for (ll i = 1; i <= n; i ++)
cin >> a[i];
for (ll i = m + 1; i < N; i ++)
dp[0][i] = 1e9;
for (ll i = 1; i <= n; i ++){
for (ll x = 0; x < N; x ++)
dp[i][x] = dp[i - 1][x] + (x != a[i]);
for (ll x = N - 1 - m; x < N; x ++)
dp[i][N - 1] = min(dp[i][N - 1], dp[i][x]);
for (ll x = N - 2; x >= 0; x --)
dp[i][x] = min(dp[i][x + 1], dp[i][max(0ll, x - m)]);
}
cout << dp[n][0] << endl;
}
# | 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... |