Submission #1101472

#TimeUsernameProblemLanguageResultExecution timeMemory
1101472vinhluanK blocks (IZhO14_blocks)C++17
0 / 100
1 ms336 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define int long long #define se second #define fi first #define pb push_back int n,k; int a[100005]; int dp[100005][104]; signed main(){ cin>>n>>k; for (int i=1;i<=n;i++){ cin>>a[i]; } for (int i=1;i<=k;i++){ for (int j=1;j<=n;j++){ dp[i][j]=INT_MAX; } } for (int i=1;i<=n;i++){ int maxx=0; maxx=max(maxx,a[i]); dp[1][i]=maxx; } for (int i=1;i<=k;i++){ for (int j=i;j<=n;j++){ int maxx=0; for (int l=j;l>=i;l--){ maxx=max(maxx,a[l]); dp[i][j]=min(dp[i][j],dp[i-1][l-1]+maxx); } } } cout<<dp[k][n]; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...