# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1247825 | free_de_la_zenith | K blocks (IZhO14_blocks) | C++20 | 1099 ms | 82624 KiB |
/**
* author: MINHTPC
*
**/
#include <bits/stdc++.h>
#define ll long long
#define fi first
#define se second
#define pb push_back
#define all(a) a.begin() , a.end()
#define FOR(i ,a , b) for(int i = a ; i <= b ; ++i)
#define bit(mask,i) ((mask>>i)&1)
#define name "task"
#define lo lower_bound
#define up upper_bound
#define count_bit1(x) __builtin_popcountll(x)
#define count_bit01(x) __builtin_clzll(x)
#define count_bit10(x) __builtin_ctzll(x)
using namespace std;
const int N=1e5+5;
const long long INF=1e18;
long long a[N],n,k,dp[105][N];
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);cout.tie(0);
if(fopen("umnik.inp","r")) {
freopen("umnik.inp","r",stdin);
// freopen("umnik.out","w",stdout);
}
memset(dp,60,sizeof dp);
cin >> n >> k;
for(int i=1;i<=n;i++) cin >> a[i];
dp[0][0]=0;
for(int i=1;i<=n;i++) {
for(int d=1;d<=k;d++) {
dp[d][i]=INF;
long long mx=0;
for(int j=i;j>=1;j--) {
mx=max(mx,a[j]);
dp[d][i]=min(dp[d][i],dp[d-1][j-1]+mx);
}
}
}
cout << dp[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... |