結果

問題 No.1015 おつりは要らないです
ユーザー potoooooooopotoooooooo
提出日時 2020-04-03 21:31:46
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 137 ms / 2,000 ms
コード長 1,108 bytes
コンパイル時間 1,697 ms
コンパイル使用メモリ 170,632 KB
実行使用メモリ 8,192 KB
最終ジャッジ日時 2024-04-29 01:10:06
合計ジャッジ時間 5,534 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 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 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 131 ms
7,808 KB
testcase_11 AC 132 ms
7,936 KB
testcase_12 AC 118 ms
7,808 KB
testcase_13 AC 121 ms
8,064 KB
testcase_14 AC 137 ms
8,064 KB
testcase_15 AC 117 ms
7,680 KB
testcase_16 AC 122 ms
7,808 KB
testcase_17 AC 128 ms
8,064 KB
testcase_18 AC 119 ms
7,808 KB
testcase_19 AC 120 ms
8,064 KB
testcase_20 AC 115 ms
7,936 KB
testcase_21 AC 110 ms
7,936 KB
testcase_22 AC 114 ms
7,936 KB
testcase_23 AC 109 ms
7,680 KB
testcase_24 AC 118 ms
7,936 KB
testcase_25 AC 109 ms
7,808 KB
testcase_26 AC 102 ms
7,808 KB
testcase_27 AC 107 ms
7,936 KB
testcase_28 AC 104 ms
7,808 KB
testcase_29 AC 107 ms
7,936 KB
testcase_30 AC 2 ms
5,376 KB
testcase_31 AC 40 ms
8,064 KB
testcase_32 AC 40 ms
8,192 KB
testcase_33 AC 50 ms
8,064 KB
testcase_34 AC 1 ms
5,376 KB
testcase_35 AC 2 ms
5,376 KB
testcase_36 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n, x, y, z; cin >> n >> x >> y >> z;
    multiset<int> ms;
    for (int i = 0; i < n; i++) {
        int a; cin >> a; ms.emplace(a);
    }
    while (z && !ms.empty()) {
        auto w = *ms.rbegin();
        ms.erase(ms.find(w));
        if (w < 10000) {
            z--; continue;
        }
        int m = min(z, w / 10000);
        w -= m * 10000;
        z -= m;
        ms.emplace(w);
    }
    while (y && !ms.empty()) {
        auto w = *ms.rbegin();
        ms.erase(ms.find(w));
        if (w < 5000) {
            y--; continue;
        }
        int m = min(y, w / 5000);
        w -= m * 5000;
        y -= m;
        ms.emplace(w);
    }
    while (x && !ms.empty()) {
        auto w = *ms.rbegin();
        ms.erase(ms.find(w));
        if (w < 1000) {
            x--; continue;
        }
        int m = min(x, w / 1000);
        w -= m * 1000;
        x -= m;
        ms.emplace(w);
    }
    if (ms.empty()) cout << "Yes\n";
    else cout << "No\n"; 
    return 0;
}
0