結果

問題 No.1015 おつりは要らないです
ユーザー knshnbknshnb
提出日時 2020-04-06 16:33:05
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 37 ms / 2,000 ms
コード長 1,447 bytes
コンパイル時間 1,897 ms
コンパイル使用メモリ 206,128 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-29 05:08:42
合計ジャッジ時間 3,791 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 1 ms
5,376 KB
testcase_07 AC 1 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 35 ms
5,376 KB
testcase_11 AC 35 ms
5,376 KB
testcase_12 AC 33 ms
5,376 KB
testcase_13 AC 33 ms
5,376 KB
testcase_14 AC 34 ms
5,376 KB
testcase_15 AC 32 ms
5,376 KB
testcase_16 AC 33 ms
5,376 KB
testcase_17 AC 35 ms
5,376 KB
testcase_18 AC 34 ms
5,376 KB
testcase_19 AC 33 ms
5,376 KB
testcase_20 AC 34 ms
5,376 KB
testcase_21 AC 34 ms
5,376 KB
testcase_22 AC 35 ms
5,376 KB
testcase_23 AC 35 ms
5,376 KB
testcase_24 AC 37 ms
5,376 KB
testcase_25 AC 35 ms
5,376 KB
testcase_26 AC 37 ms
5,376 KB
testcase_27 AC 35 ms
5,376 KB
testcase_28 AC 35 ms
5,376 KB
testcase_29 AC 37 ms
5,376 KB
testcase_30 AC 2 ms
5,376 KB
testcase_31 AC 10 ms
5,376 KB
testcase_32 AC 11 ms
5,376 KB
testcase_33 AC 17 ms
5,376 KB
testcase_34 AC 2 ms
5,376 KB
testcase_35 AC 1 ms
5,376 KB
testcase_36 AC 1 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>  // clang-format off
using Int = long long;
#define REP_(i, a_, b_, a, b, ...) for (Int i = (a), lim##i = (b); i < lim##i; i++)
#define REP(i, ...) REP_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
struct SetupIO { SetupIO() { std::cin.tie(nullptr), std::ios::sync_with_stdio(false), std::cout << std::fixed << std::setprecision(13); } } setup_io;
#ifndef _MY_DEBUG
#define dump(...)
#endif  // clang-format on

/**
 *    author:  knshnb
 *    created: Mon Apr  6 16:02:49 JST 2020
 **/

signed main() {
    Int n, x, y, z;
    std::cin >> n >> x >> y >> z;
    std::priority_queue<Int> pq;
    REP(i, n) {
        Int a;
        std::cin >> a;
        pq.push(a + 1);
    }
    while (pq.size()) {
        Int a = pq.top();
        pq.pop();
        if (z > 0) {
            if (a < 10000) {
                z--;
            } else {
                Int use = std::min(z, a / 10000);
                z -= use, a -= use * 10000;
                pq.push(a);
            }
        } else if (y > 0) {
            if (a < 5000) {
                y--;
            } else {
                Int use = std::min(y, a / 5000);
                y -= use, a -= use * 5000;
                pq.push(a);
            }
        } else {
            pq.push(a);
            break;
        }
    }
    while (pq.size()) {
        x -= (pq.top() + 999) / 1000;
        pq.pop();
    }
    std::cout << (x >= 0 ? "Yes" : "No") << std::endl;
}
0