Submission #1094697

#TimeUsernameProblemLanguageResultExecution timeMemory
1094697irmuunK blocks (IZhO14_blocks)C++17
53 / 100
1014 ms3420 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define pb push_back #define ff first #define ss second #define all(s) s.begin(),s.end() #define rall(s) s.rbegin(),s.rend() int main(){ ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); ll n,k; cin>>n>>k; ll a[n+5]; for(ll i=1;i<=n;i++){ cin>>a[i]; } ll dp[n+5][k+5]; for(ll i=0;i<=n;i++){ for(ll j=0;j<=k;j++){ dp[i][j]=1e18; } } dp[0][0]=0; for(ll r=1;r<=n;r++){ ll mx=0; for(ll l=r;l>=1;l--){ mx=max(mx,a[l]); for(ll i=1;i<=k;i++){ dp[r][i]=min(dp[r][i],dp[l-1][i-1]+mx); } } } cout<<dp[n][k]; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...