제출 #216924

#제출 시각아이디문제언어결과실행 시간메모리
216924someone_aaK개의 묶음 (IZhO14_blocks)C++17
53 / 100
5 ms512 KiB
#include <bits/stdc++.h> #define ll long long #define pb push_back #define mp make_pair using namespace std; const int maxn = 110; int n, k; int dp[maxn][maxn]; int a[maxn]; int main() { cin>>n>>k; int prefmax = 0; for(int i=1;i<=n;i++) { cin>>a[i]; prefmax = max(prefmax, a[i]); dp[i][1] = prefmax; } for(int d=2;d<=k;d++) { for(int i=d;i<=n;i++) { dp[i][d] = INT_MAX; int prefmax = 0; for(int p=i;p>=d;p--) { prefmax = max(prefmax, a[p]); dp[i][d] = min(dp[i][d], dp[p-1][d-1] + prefmax); } } } cout<<dp[n][k]<<"\n"; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...