結果
問題 | No.266 最終進化を目指せ |
ユーザー |
![]() |
提出日時 | 2015-08-07 23:02:20 |
言語 | C++11 (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 701 bytes |
コンパイル時間 | 278 ms |
コンパイル使用メモリ | 43,392 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-18 05:15:19 |
合計ジャッジ時間 | 991 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 24 |
コンパイルメッセージ
main.cpp: In function ‘int getInt()’: main.cpp:5:34: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 5 | inline int getInt(){ int s; scanf("%d", &s); return s; } | ~~~~~^~~~~~~~~~
ソースコード
#define REP(i,n) for(int i=0; i<(int)(n); i++)#include <queue>#include <cstdio>inline int getInt(){ int s; scanf("%d", &s); return s; }#include <set>using namespace std;int dp[16][16];int main(){const int n = getInt();vector<int> s(n + 1);REP(i,n+1) s[i] = getInt();const int inf = 1 << 29;REP(i,n+1) REP(j,s[i]+1) dp[i][j] = inf;dp[0][0] = 1;REP(i,n+1){if(i != 0){REP(j,s[i-1]+1) dp[i][j] = dp[i-1][j] + 1;}REP(j,s[i]+1){REP(k,j) dp[i][j] = min(dp[i][j], dp[i][k] + dp[i][j - k - 1]);// printf("%d %d: %2d\n", i, j, dp[i][j] == inf ? -1 : dp[i][j]);}}REP(i,s[n]+1) printf("%d ", dp[n][i]); puts("");return 0;}