結果

問題 No.1015 おつりは要らないです
ユーザー tomatoma
提出日時 2020-04-03 21:28:13
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 76 ms / 2,000 ms
コード長 1,726 bytes
コンパイル時間 1,849 ms
コンパイル使用メモリ 169,072 KB
実行使用メモリ 4,388 KB
最終ジャッジ日時 2023-08-11 08:36:18
合計ジャッジ時間 5,733 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,388 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 73 ms
4,380 KB
testcase_11 AC 76 ms
4,380 KB
testcase_12 AC 71 ms
4,380 KB
testcase_13 AC 73 ms
4,380 KB
testcase_14 AC 76 ms
4,376 KB
testcase_15 AC 72 ms
4,380 KB
testcase_16 AC 72 ms
4,376 KB
testcase_17 AC 75 ms
4,380 KB
testcase_18 AC 73 ms
4,380 KB
testcase_19 AC 72 ms
4,380 KB
testcase_20 AC 65 ms
4,384 KB
testcase_21 AC 64 ms
4,380 KB
testcase_22 AC 65 ms
4,376 KB
testcase_23 AC 62 ms
4,376 KB
testcase_24 AC 66 ms
4,384 KB
testcase_25 AC 65 ms
4,384 KB
testcase_26 AC 65 ms
4,380 KB
testcase_27 AC 64 ms
4,388 KB
testcase_28 AC 64 ms
4,376 KB
testcase_29 AC 65 ms
4,380 KB
testcase_30 AC 1 ms
4,376 KB
testcase_31 AC 20 ms
4,376 KB
testcase_32 AC 20 ms
4,380 KB
testcase_33 AC 44 ms
4,380 KB
testcase_34 AC 1 ms
4,380 KB
testcase_35 AC 1 ms
4,376 KB
testcase_36 AC 1 ms
4,384 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include"bits/stdc++.h"
using namespace std;
#define REP(k,m,n) for(int (k)=(m);(k)<(n);(k)++)
#define rep(i,n) REP((i),0,(n))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using tp3 = tuple<int, int, int>;
using Mat = vector<vector<ll>>;
constexpr int INF = 1 << 28;
constexpr ll INFL = 1ll << 60;
constexpr int dh[4] = { 0,1,0,-1 };
constexpr int dw[4] = { -1,0,1,0 };
bool isin(const int H, const int W, const int h, const int w) {
    return 0 <= h && h < H && 0 <= w && w < W;
}
template<typename T>
T minch(T& l, T r) {
    return l = min(l, r);
}
template<typename T>
T maxch(T& l, T r) {
    return l = max(l, r);
}
template<typename T>
void output(const T& val) {
    cout << val << endl;
}
template<typename T>
void output(const vector<T>& vec, const bool newline = false) {
    for (const T& val : vec)cout << val << (newline ? '\n' : ' '); cout << endl;
}
template<typename T>
void output(const vector<vector<T>>& mat) {
    for (const auto& row : mat)output(row);
}
// ============ template finished ============

void use_bill(priority_queue<ll>& pq, ll cnt, ll price) {
    while (!pq.empty() && cnt > 0) {
        ll now = pq.top(); pq.pop();
        ll use = now / price;
        if (use == 0) {
            cnt--;
        }
        else {
            use = min(use, cnt);
            cnt -= use;
            now -= use * price;
            pq.push(now);
        }
    }
}

int main()
{
    ll N, X, Y, Z;
    cin >> N >> X >> Y >> Z;
    priority_queue<ll> pq;
    rep(i, N) {
        ll tmp;
        cin >> tmp;
        pq.push(tmp);
    }
    use_bill(pq, Z, 10000);
    use_bill(pq, Y, 5000);
    use_bill(pq, X, 1000);
    output(pq.empty() ? "Yes" : "No");
    return 0;
}
0