Submission #870014

#TimeUsernameProblemLanguageResultExecution timeMemory
870014truongdoan2012K blocks (IZhO14_blocks)C++17
0 / 100
11 ms80124 KiB
#include <bits/stdc++.h> using namespace std; #ifdef LOCAL #include "algo/debug.h" #else #define debug(...) 42 #endif using i64 = long long; const int N = 1e5 + 10; i64 dp[N][101]; // min val khi chia i phan tu vao j nhom i64 a[N]; void solve() { int n, k; cin >> n >> k; for (int i = 1; i <= n; i++) { cin >> a[i]; } memset(dp, 127, sizeof dp); dp[0][0] = 0; for (int j = 1; j <= k; j++) { for (int i = j; i <= n; i++) { for (int p = 0; p < i; p++) { dp[i][j] = min(dp[i][j], dp[p][j - 1] + a[i]); } } } cout << dp[n][k]; } int main() { cin.tie(nullptr)->sync_with_stdio(false); int TC = 1; // cin >> TC; while (TC--) { solve(); } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...