結果

問題 No.842 初詣
ユーザー oooooba
提出日時 2021-04-27 22:02:36
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 691 bytes
コンパイル時間 937 ms
コンパイル使用メモリ 111,660 KB
最終ジャッジ日時 2025-01-21 01:26:56
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <array>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <optional>
#include <queue>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

int main() {
    array<int32_t, 6> cs;
    int32_t g;
    for (auto i = 0; i < 6; ++i) {
        cin >> cs[i];
    }
    cin >> g;
    array<int32_t, 6> xs = {500, 100, 50, 10, 5, 1};
    for (auto i = 0; i < 6; ++i) {
        g -= min(cs[i], g / xs[i]) * xs[i];
        if (g == 0) {
            cout << "YES" << endl;
            return 0;
        }
    }
    cout << "NO" << endl;
    return 0;
}
0