結果
問題 |
No.266 最終進化を目指せ
|
ユーザー |
|
提出日時 | 2020-07-04 21:10:29 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 498 bytes |
コンパイル時間 | 1,985 ms |
コンパイル使用メモリ | 192,792 KB |
最終ジャッジ日時 | 2025-01-11 15:45:34 |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 24 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:10:21: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 10 | int n; scanf("%d",&n); n++; | ~~~~~^~~~~~~~~ main.cpp:12:23: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 12 | rep(i,n) scanf("%d",&a[i]); | ~~~~~^~~~~~~~~~~~
ソースコード
#include <bits/stdc++.h> #define rep(i,n) for(int i=0;i<(n);i++) using namespace std; const int INF=1<<29; int main(){ int n; scanf("%d",&n); n++; vector<int> a(n); rep(i,n) scanf("%d",&a[i]); int dp[11][11]; rep(i,n){ dp[i][0]=i+1; for(int j=1;j<=a[i];j++){ dp[i][j]=INF; if(i>0 && j<=a[i-1]){ dp[i][j]=dp[i-1][j]+1; } rep(k,j){ dp[i][j]=min(dp[i][j],dp[i][k]+dp[i][j-k-1]); } } } rep(j,a[n-1]+1) printf("%d%c",dp[n-1][j],j<a[n-1]?' ':'\n'); return 0; }