# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
216925 | someone_aa | K blocks (IZhO14_blocks) | C++17 | 5 ms | 640 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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++) {
bool check = false;
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);
}
if(dp[i][d] < dp[i-1][d]) check = true;
}
if(check) cout<<(1/0);
}
cout<<dp[n][k]<<"\n";
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |