# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
645085 | andreast12 | K blocks (IZhO14_blocks) | C++17 | 1 ms | 656 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>
using namespace std;
#define ll long long
#define pb push_back
#define fi first
#define se second
const int mod=1e9+7, maxn=1e6+5;;
int n, k, a[105], maxi;
ll inf=1e18, dp[105][105];
int main() {
ios_base::sync_with_stdio(false); cin.tie(NULL);
cin >> n >> k;
for(int i=0; i<=n; i++) for(int kel=0; kel<=k; kel++) dp[i][kel]=inf;
dp[0][0]=0;
for(int i=1; i<=n; i++) {
cin >> a[i];
maxi=0;
for(int j=i; j>0; j--) {
maxi=max(maxi, a[j]);
for(int kel=1; kel<=k; kel++) dp[i][kel]=min(dp[i][kel], dp[j-1][kel-1]+maxi);
}
}
cout << dp[n][k] << '\n';
}
# | 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... |