Submission #93084

# Submission time Handle Problem Language Result Execution time Memory
93084 2019-01-06T11:55:58 Z Nodir_Bobiev K blocks (IZhO14_blocks) C++14
0 / 100
3 ms 504 KB
# include <iostream>

using namespace std;
	
const int N = 200;
	
int n, k;
int a[N];
long long dp[N][N];

int main()
{
	ios_base::sync_with_stdio(false);
	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 <= k; j++){
			dp[i][j] = 1e9 + 1;
		}
	}
	
	for (int i = 1; i <= n; i++){
		for (int j = 1; j <= min(k, i); j++){
			int mx = a[i];
			for (int k = i - 1; k >= j - 1; k--){
				dp[i][j] = min(dp[i][j], dp[k][j - 1] + mx);
				mx = max(mx, a[k]);
			}
		}
	}
	/*
	for (int i = 1; i <= n; i++){
		for (int j = 1; j <= k; j++){
			cout << dp[i][j] << ' ';
		}
		cout << endl;
	}
	*/
	
	cout << dp[n][k];
	
}
/*

5 1
1 2 3 4 5


5 5
1 2 3 4 5


*/ 

# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Incorrect 2 ms 376 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Incorrect 2 ms 376 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 504 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 3 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -