Submission #332774

# Submission time Handle Problem Language Result Execution time Memory
332774 2020-12-03T10:14:52 Z nandonathaniel K blocks (IZhO14_blocks) C++14
0 / 100
1 ms 384 KB
#include<bits/stdc++.h>
using namespace std;
const int MAXN=100005,MAXK=105;
long long dp[MAXN][MAXK];
int a[MAXN];

int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int N,K;
	cin >> N >> K;
	for(int i=1;i<=N;i++)cin >> a[i];
	for(int i=1;i<=N;i++){
		for(int j=1;j<=min(i,K);j++){
			dp[i][j]=1e18;
			int maxi=a[i];
			for(int k=i-1;k>=0;k--){
				if(k>=j-1)dp[i][j]=min(dp[i][j],dp[k][j-1]+maxi);
				maxi=max(maxi,a[k]);
			}
		}
	}
	cout << dp[N][K] << '\n';
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Incorrect 1 ms 364 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Incorrect 1 ms 384 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Incorrect 1 ms 364 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Incorrect 1 ms 364 KB Output isn't correct
3 Halted 0 ms 0 KB -