# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
39304 | MrPlany | K개의 묶음 (IZhO14_blocks) | C++14 | 1000 ms | 45032 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
int n, a[100109], dp[109][100109], 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;
}
}
for(int i=1;i<=k;i++){
for(int j=1;j<=n;j++){
cout << dp[i][j] << " ";
}
cout << endl;
}
cout << dp[k][n];
return 0;
}
컴파일 시 표준 에러 (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... |