| # | Time | Username | Problem | Language | Result | Execution time | Memory | 
|---|---|---|---|---|---|---|---|
| 39281 | MrPlany | K blocks (IZhO14_blocks) | C++14 | 0 ms | 2060 KiB | 
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
int n, a[109], dp[109][109], k;
int main(){
	
	scanf("%d%d",&n,&k);
//	if(n>100) return 0;
	
	for(int i=1;i<=n;i++) scanf("%d",a+i);
	
	for(int i=1;i<=n;i++) dp[1][i] = max(dp[1][i-1], a[i]);
	
	for(int i=2;i<=n;i++){
		
		for(int j=i;j<=n;j++){
			
			long long mx = 0, mn=1e9;
			
			for(int f = j; f>=i; f--){
				mx = max(mx, (long long)a[f]);
				
				mn= min( mx + dp[i-1][f-1], mn );
				
			}
			dp[i][j] = mn;
			
		}
		
	}
	
	cout << dp[k][n];
	return 0;
}
Compilation message (stderr)
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
