Submission #345654

# Submission time Handle Problem Language Result Execution time Memory
345654 2021-01-07T18:54:40 Z shmad K blocks (IZhO14_blocks) C++14
0 / 100
1 ms 364 KB
#include <bits/stdc++.h>
 
#define nl '\n'
#define pb push_back
#define E exit(0)
#define all(v) v.begin(),v.end()
#define ff first
#define ss second
#define sz(s) (s).size()

using namespace std;
using ll=long long;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
 
const int N=1e6+5;
const int INF=1e9+7;
const int eps=1e-6;

void solve() {
	int n,k;
	cin>>n>>k;
	int a[n+1],dp[n+1][k+1];
	for (int i=1;i<=n;i++) cin>>a[i];
	for (int i=0;i<=n;i++) for (int j=0;j<=k;j++) dp[i][j]=INF;
	dp[0][0]=0;
	for (int i=1;i<=n;i++) {
		for (int q=1;q<=k;q++) {
			int mx=0;
			for (int j=i;j>=0;j--) {
				mx=max(mx,a[j]);
				dp[i][q]=min(dp[j-1][q-1]+mx,dp[i][q]);
			}
		}
	}
	cout<<dp[n][k];
}

ll test=1;

int main () {
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
    ios_base::sync_with_stdio(0);
	cin.tie();
//	cin>>test;
    while (test--) solve();
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 0 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 0 ms 364 KB Output is correct
9 Incorrect 1 ms 364 KB Output isn't correct
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 0 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 1 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 1 ms 364 KB Output is correct
9 Incorrect 1 ms 364 KB Output isn't correct
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 0 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 0 ms 364 KB Output is correct
9 Incorrect 1 ms 364 KB Output isn't correct
10 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
5 Correct 1 ms 364 KB Output is correct
6 Correct 0 ms 364 KB Output is correct
7 Correct 1 ms 364 KB Output is correct
8 Correct 0 ms 364 KB Output is correct
9 Incorrect 1 ms 364 KB Output isn't correct
10 Halted 0 ms 0 KB -