結果

問題 No.1015 おつりは要らないです
ユーザー kuhaku
提出日時 2025-05-07 16:50:00
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 59 ms / 2,000 ms
コード長 801 bytes
コンパイル時間 1,222 ms
コンパイル使用メモリ 104,568 KB
実行使用メモリ 7,844 KB
最終ジャッジ日時 2025-05-07 16:50:06
合計ジャッジ時間 5,263 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 33
権限があれば一括ダウンロードができます

ソースコード

diff #

// competitive-verifier: PROBLEM https://yukicoder.me/problems/no/1015
#include <algorithm>
#include <iostream>
#include <vector>
int main(void) {
    int n;
    std::vector<int> x(3);
    std::cin >> n >> x[0] >> x[1] >> x[2];
    std::vector<int> a(n);
    for (auto &e : a) std::cin >> e, ++e;
    std::vector<int> y = {1000, 5000, 10000};
    for (int k = 2; k >= 0; --k) {
        for (int i = 0; i < n; ++i) {
            int t = std::min(x[k], a[i] / y[k]);
            x[k] -= t;
            a[i] -= t * y[k];
        }
        std::sort(a.begin(), a.end(), std::greater<>());
        for (int i = 0; i < std::min(n, x[k]); ++i) a[i] = 0;
    }
    if (*std::max_element(a.begin(), a.end()) == 0) {
        std::cout << "Yes\n";
    } else {
        std::cout << "No\n";
    }
    return 0;
}
0