Submission #93079

# Submission time Handle Problem Language Result Execution time Memory
93079 2019-01-06T11:41:45 Z Nodir_Bobiev K blocks (IZhO14_blocks) C++14
0 / 100
2 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] = 1e8 + 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]);
			}
		}
	}
	
	cout << dp[n][k];
	
}
/*

5 1
1 2 3 4 5


5 2
1 2 3 4 5


*/ 

# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Incorrect 2 ms 380 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 2 ms 504 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -