Submission #1166708

#TimeUsernameProblemLanguageResultExecution timeMemory
1166708tamyteRabbit Carrot (LMIO19_triusis)C++20
35 / 100
196 ms196424 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); // #ifndef ONLINE_JUDGE // ifstream cin("input.txt"); // #endif // ONLINE_JUDGE int N, M; cin >> N >> M; vector<int> a(N); for (int i = 0; i < N; ++i) { cin >> a[i]; } const int MAX = 10000; vector<vector<int>> dp(N + 1, vector<int>(MAX + 1, 2 * N + 5)); dp[0][0] = 0; for (int i = 0; i < N; ++i) { for (int j = 0; j <= MAX; ++j) { if (a[i] - j <= M) { dp[i + 1][a[i]] = min(dp[i + 1][a[i]], dp[i][j]); } if (j + M <= MAX) { dp[i + 1][j + M] = min(dp[i + 1][j + M], dp[i][j] + 1); } } } int res = N; for (int i = 0; i <= MAX; ++i) { res = min(res, dp[N][i]); } cout << res << 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...