結果
問題 | No.842 初詣 |
ユーザー |
|
提出日時 | 2021-06-22 23:53:46 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 653 bytes |
コンパイル時間 | 1,716 ms |
コンパイル使用メモリ | 193,468 KB |
最終ジャッジ日時 | 2025-01-22 11:41:48 |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 21 |
ソースコード
#include <bits/stdc++.h> using namespace std; bool dp[7][7005]; int arr[6]; int coin[6] = { 500,100,50,10,5,1 }; int main(void) { cin.tie(0); ios::sync_with_stdio(false); int G; cin >> arr[0] >> arr[1] >> arr[2] >> arr[3] >> arr[4] >> arr[5] >> G; memset(dp, false, sizeof(dp)); dp[0][0] = true; for (int i = 0; i < 6; i++) { for (int j = 0; j <= 7000; j++) { if (dp[i][j] == false) continue; dp[i + 1][j] = true; for (int k = 0; k <= arr[i]; k++) { if (j + (coin[i] * k) > 7000) break; dp[i + 1][j + (coin[i] * k)] = true; } } } if (dp[6][G]) cout << "YES" << '\n'; else cout << "NO" << '\n'; return 0; }