結果
問題 | No.842 初詣 |
ユーザー |
|
提出日時 | 2019-06-28 22:47:00 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 4 ms / 2,000 ms |
コード長 | 637 bytes |
コンパイル時間 | 1,436 ms |
コンパイル使用メモリ | 166,416 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-07-02 05:02:31 |
合計ジャッジ時間 | 2,301 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 21 |
ソースコード
#include <bits/stdc++.h> using namespace std; using ll = long long; using vi = vector<int>; using vll = vector<ll>; using vvi = vector<vector<int>>; using vvl = vector<vector<ll>>; int main() { cin.tie(nullptr); ios::sync_with_stdio(false); int v[] = {500, 100, 50, 10, 5, 1}; int a[6], b; cin >> a[0] >> a[1] >> a[2] >> a[3] >> a[4] >> a[5] >> b; set<ll> s; s.insert(0); for (int i = 0; i < 6; i++) { set<ll> t; for (int j = 0; j <= a[i]; j++) { for (auto &k : s) t.insert(k + v[i] * j); } s = t; } if (s.find(b) == s.end()) cout << "NO" << endl; else cout << "YES" << endl; return 0; }