結果

問題 No.1015 おつりは要らないです
ユーザー けーむけーむ
提出日時 2020-05-25 23:32:04
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 43 ms / 2,000 ms
コード長 2,092 bytes
コンパイル時間 1,477 ms
コンパイル使用メモリ 176,676 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-29 06:15:06
合計ジャッジ時間 3,390 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 1 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 1 ms
5,376 KB
testcase_08 AC 1 ms
5,376 KB
testcase_09 AC 1 ms
5,376 KB
testcase_10 AC 39 ms
5,376 KB
testcase_11 AC 40 ms
5,376 KB
testcase_12 AC 37 ms
5,376 KB
testcase_13 AC 39 ms
5,376 KB
testcase_14 AC 43 ms
5,376 KB
testcase_15 AC 38 ms
5,376 KB
testcase_16 AC 39 ms
5,376 KB
testcase_17 AC 41 ms
5,376 KB
testcase_18 AC 39 ms
5,376 KB
testcase_19 AC 40 ms
5,376 KB
testcase_20 AC 36 ms
5,376 KB
testcase_21 AC 34 ms
5,376 KB
testcase_22 AC 33 ms
5,376 KB
testcase_23 AC 33 ms
5,376 KB
testcase_24 AC 35 ms
5,376 KB
testcase_25 AC 33 ms
5,376 KB
testcase_26 AC 33 ms
5,376 KB
testcase_27 AC 35 ms
5,376 KB
testcase_28 AC 35 ms
5,376 KB
testcase_29 AC 35 ms
5,376 KB
testcase_30 AC 1 ms
5,376 KB
testcase_31 AC 10 ms
5,376 KB
testcase_32 AC 9 ms
5,376 KB
testcase_33 AC 14 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>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())
#define endl "\n"

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    ll n, x, y, z;
    cin >> n >> x >> y >> z;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    priority_queue<ll> pq;
    rep(i, n) pq.push(a[i] + 1);
    while((!pq.empty()) && (z > 0)) {
        ll v = pq.top(); pq.pop();
        ll zc = min(z, v / 10000);
        if (zc == 0) {
            pq.push(v);
            break;
        }
        z -= zc;
        v -= zc * 10000;
        if (v > 0) pq.push(v);
    }
    while((!pq.empty()) && (z > 0)) {
        ll v = pq.top(); pq.pop();
        v -= 10000;
        z--;
        if (v > 0) pq.push(v);
    }
    while((!pq.empty()) && (y > 0)) {
        ll v = pq.top(); pq.pop();
        ll yc = min(y, v / 5000);
        if (yc == 0) {
            pq.push(v);
            break;
        }
        y -= yc;
        v -= yc * 5000;
        if (v > 0) pq.push(v);
    }
    while((!pq.empty()) && (y > 0)) {
        ll v = pq.top(); pq.pop();
        v -= 5000;
        y--;
        if (v > 0) pq.push(v);
    }
    while((!pq.empty()) && (x > 0)) {
        ll v = pq.top(); pq.pop();
        ll xc = min(x, v / 1000);
        if (xc == 0) {
            pq.push(v);
            break;
        }
        x -= xc;
        v -= xc * 1000;
        if (v > 0) pq.push(v);
    }
    while((!pq.empty()) && (x > 0)) {
        ll v = pq.top(); pq.pop();
        v -= 1000;
        x--;
        if (v > 0) pq.push(v);
    }
    if (sz(pq) > 0) {
        cout << "No" << endl;
    }
    else {
        cout << "Yes" << endl;
    }
    return 0;
}
0