Submission #00183
ソースコード
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | #include <iostream> #include <cstring> #include <algorithm> using namespace std; const int INF = 1<<29; // 十分大きい値にする, INT_MAX にしないのはオーバーフロー対策 // 入力 int n, A; int a[110]; // DPテーブル int dp[110][10010]; int main() { cin >> n >> A; for ( int i = 0; i < n; ++i) cin >> a[i]; // 一旦すべて INF に for ( int i = 0; i < 110; ++i) for ( int j = 0; j < 10010; ++j) dp[i][j] = INF; dp[0][0] = 0; // dp[0][0] だけ 0 に for ( int i = 0; i < n; ++i) { for ( int j = 0; j <= A; ++j) { dp[i+1][j] = min(dp[i+1][j], dp[i][j]); if (j >= a[i]) dp[i+1][j] = min(dp[i+1][j], dp[i][j-a[i]] + 1); } } if (dp[n][A] < INF) cout << dp[n][A] << endl; else cout << -1 << endl; return 0; |
ステータス
項目 | データ |
---|---|
問題 | 0004 - 集会所 |
ユーザー名 | ebitomato |
投稿日時 | 2020-08-17 11:15:14 |
言語 | C++ |
状態 | Compile Error |
得点 | 0 |
ソースコード長 | 834 Byte |
最大実行時間 | - |
最大メモリ使用量 |
コンパイルメッセージ
./Main.cpp: In function ‘int main()’: ./Main.cpp:32:11: error: expected ‘}’ at end of input return 0; ^ ./Main.cpp:15:12: note: to match this ‘{’ int main() { ^
セット
セット | 得点 | Cases |
---|
テストケース
ファイル名 | 状態 | 実行時間 | メモリ使用量 | # |
---|