Submission #829100

#TimeUsernameProblemLanguageResultExecution timeMemory
829100vjudge1K blocks (IZhO14_blocks)C++17
0 / 100
1 ms340 KiB
#include <bits/stdc++.h> using namespace std; #define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0) #define ll long long #define pii pair<int, int> #define pll pair<ll, ll> #define pb push_back #define fi first #define se second int n, m, x; int a[1001], dp[1001][1001]; int main() { fastio; cin >> n >> m; for (int i = 1; i <= n; i++) { cin >> a[i]; } for (int i = 0; i <= n; i++) { for (int j = 0; j <= m; j++) { dp[i][j] = 1e9; } } dp[0][0] = 0; for (int i = 1; i <= n; i++) { for (int j = 1; j <= min(i, m); j++) { x = a[i]; for (int k = i - 1; k >= 0; k--) { x = max(a[k], x); dp[i][j] = min(dp[i][j], dp[k][j - 1]+x); } } } cout << dp[n][m] << 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...