답안 #1101465

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1101465 2024-10-16T08:46:19 Z vinhluan K개의 묶음 (IZhO14_blocks) C++14
0 / 100
1 ms 336 KB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define int long long 
#define se second
#define fi first
#define pb push_back
int n,k;
int a[100005];
int dp[100005][104];
signed main(){
	cin>>n>>k;
    for (int i=1;i<=n;i++){
    	cin>>a[i];
	}
	for (int i=1;i<=k;i++){
		for (int j=1;j<=n;j++){
			dp[i][j]=INT_MAX;
		}
	}
	for (int i=1;i<=n;i++){
	int maxx=0;
	maxx=max(maxx,a[i]);
	dp[1][i]=maxx;
	}
	
	for (int i=2;i<=k;i++){
		for (int j=i;j<=n;j++){
			int maxx=0;
			for (int l=j;l>=i;l--){
				maxx=max(maxx,a[l]);
				dp[i][j]=min(dp[i][j],dp[i-1][l-1]+maxx);
			}
		}
	}
	cout<<dp[k][n];
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Incorrect 1 ms 336 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Incorrect 1 ms 336 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Incorrect 1 ms 336 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 336 KB Output is correct
2 Incorrect 1 ms 336 KB Output isn't correct
3 Halted 0 ms 0 KB -