Submission #335920

# Submission time Handle Problem Language Result Execution time Memory
335920 2020-12-14T09:58:03 Z nafis_shifat K blocks (IZhO14_blocks) C++14
0 / 100
1 ms 364 KB
#include<bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
using namespace std;
const int mxn=1e5+5;
const int inf=1e9;
int main() {
	int n,K;
	cin>>n>>K;
	int a[n+1];
	for(int i = 1; i <= n; i++) cin>>a[i];


	int dp[n+1][K+1];


    
    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 j = 0; j <= min(i,K); j ++) {
    		int cm = a[i];
    		for(int k = i - 1; k >= 0; k--) {
    			dp[i][j] = min(dp[i][j],dp[k][j-1] + cm);
    			cm = max(cm,a[k]);
    		}
    	}
    }
	

	cout<<dp[n][K]<<endl;
}
# 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 Incorrect 1 ms 364 KB Output isn't correct
7 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 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 Incorrect 1 ms 364 KB Output isn't correct
7 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 Incorrect 1 ms 364 KB Output isn't correct
7 Halted 0 ms 0 KB -