제출 #1164782

#제출 시각아이디문제언어결과실행 시간메모리
1164782Ghulam_JunaidRabbit Carrot (LMIO19_triusis)C++20
35 / 100
124 ms196232 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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...