Submission #345412

#TimeUsernameProblemLanguageResultExecution timeMemory
345412mansurK blocks (IZhO14_blocks)C++14
0 / 100
1 ms364 KiB
#include<bits/stdc++.h> using namespace std; #define all(a) a.begin(),a.end() #define ll long long #define pb push_back #define nl '\n' #define popb pop_back() #define sz size() #define ld long double #define ull unsigned long long #define F first #define S second #define fix fixed<<setprecision #define pii pair<int,int> #define E exit (0) #define int long long const int inf=1e9; int dp[100001][101]; signed main() { //freopen("planting.in","r",stdin); //freopen("planting.out","w",stdout); ios_base::sync_with_stdio(false); cin.tie(NULL); int n,k; cin>>n>>k; int c[n+1]; for (int i=1;i<=n;i++) { cin>>c[i]; dp[0][i]=inf; } for (int i=1;i<=n;i++) { for (int j=1;j<=k;j++) { dp[i][j]=inf; for (int s=i-1,mx=0;s>=0;s--) { mx=max(mx,c[s+1]); dp[i][j]=min(dp[s][j-1]+mx,dp[i][j]); } } } 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...