Submission #114072

# Submission time Handle Problem Language Result Execution time Memory
114072 2019-05-29T19:35:51 Z ioilolcom K blocks (IZhO14_blocks) C++14
53 / 100
7 ms 512 KB
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
typedef long long int ll;
const int N=105;
int a[N];
int n;

ll dp[N][N];
int v;
int query(int l,int r){
	int ans=0;
	for(int i=l; i<=r; i++) {
		ans=max(ans,a[i]);
	}
	return ans;
}
int  solve(int idx,int k){

	if(idx==n+1) {
		if(k==v+1) {
			return 0;
		}
		return 1e9;
	}
	if(dp[idx][k]!=-1) {
		return dp[idx][k];
	}
	int ans=1e9;
	for(int j=idx; j<=n; j++) {
		ans=min(ans,query(idx,j)+solve(j+1,k+1));
	}
	return dp[idx][k]=ans;
}
int main()
{

	ios_base:: sync_with_stdio(false); cin.tie(0);
	cin>>n>>v;
	for(int i=1; i<=n; i++) cin>>a[i];
	memset(dp,-1,sizeof dp);
	ll ans=solve(1,1);

	cout<<ans<<endl;
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 512 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 2 ms 512 KB Output is correct
9 Correct 3 ms 512 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 2 ms 384 KB Output is correct
12 Correct 7 ms 384 KB Output is correct
13 Correct 6 ms 512 KB Output is correct
14 Correct 6 ms 384 KB Output is correct
15 Correct 6 ms 384 KB Output is correct
16 Correct 6 ms 384 KB Output is correct
17 Correct 7 ms 384 KB Output is correct
18 Correct 7 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 512 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 2 ms 512 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 2 ms 384 KB Output is correct
12 Correct 2 ms 384 KB Output is correct
13 Correct 2 ms 384 KB Output is correct
14 Correct 2 ms 512 KB Output is correct
15 Correct 2 ms 384 KB Output is correct
16 Correct 2 ms 384 KB Output is correct
17 Correct 2 ms 384 KB Output is correct
18 Correct 2 ms 384 KB Output is correct
19 Correct 2 ms 384 KB Output is correct
20 Correct 2 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 512 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 2 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 2 ms 512 KB Output is correct
9 Correct 2 ms 384 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 2 ms 512 KB Output is correct
12 Correct 2 ms 384 KB Output is correct
13 Correct 6 ms 384 KB Output is correct
14 Correct 6 ms 384 KB Output is correct
15 Correct 6 ms 512 KB Output is correct
16 Correct 7 ms 512 KB Output is correct
17 Correct 6 ms 512 KB Output is correct
18 Correct 6 ms 512 KB Output is correct
19 Correct 6 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 3 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -