제출 #39304

#제출 시각아이디문제언어결과실행 시간메모리
39304MrPlanyK blocks (IZhO14_blocks)C++14
0 / 100
1000 ms45032 KiB
#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) 메시지

blocks.cpp: In function 'int main()':
blocks.cpp:9:21: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d",&n,&k);
                     ^
blocks.cpp:12:39: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for(int i=1;i<=n;i++) scanf("%d",a+i);
                                       ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...