結果

問題 No.1015 おつりは要らないです
ユーザー coco18000coco18000
提出日時 2020-04-03 22:01:11
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 29 ms / 2,000 ms
コード長 1,544 bytes
コンパイル時間 4,639 ms
コンパイル使用メモリ 172,980 KB
実行使用メモリ 5,036 KB
最終ジャッジ日時 2023-08-11 08:41:43
合計ジャッジ時間 3,781 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 28 ms
4,876 KB
testcase_11 AC 29 ms
4,900 KB
testcase_12 AC 28 ms
4,852 KB
testcase_13 AC 27 ms
4,768 KB
testcase_14 AC 29 ms
4,860 KB
testcase_15 AC 27 ms
4,940 KB
testcase_16 AC 27 ms
4,956 KB
testcase_17 AC 28 ms
4,796 KB
testcase_18 AC 28 ms
4,760 KB
testcase_19 AC 27 ms
4,804 KB
testcase_20 AC 27 ms
4,888 KB
testcase_21 AC 27 ms
4,868 KB
testcase_22 AC 26 ms
4,868 KB
testcase_23 AC 26 ms
4,924 KB
testcase_24 AC 27 ms
5,036 KB
testcase_25 AC 27 ms
4,876 KB
testcase_26 AC 27 ms
4,896 KB
testcase_27 AC 26 ms
4,912 KB
testcase_28 AC 26 ms
4,908 KB
testcase_29 AC 26 ms
4,816 KB
testcase_30 AC 1 ms
4,380 KB
testcase_31 AC 15 ms
4,864 KB
testcase_32 AC 15 ms
4,844 KB
testcase_33 AC 21 ms
4,856 KB
testcase_34 AC 2 ms
4,376 KB
testcase_35 AC 1 ms
4,380 KB
testcase_36 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

ll N, X, Y, Z;
ll A[100005];

bool check() {
    sort(A, A + N);
    vector<ll> v;
    REP(i, N) {
        ll m = (A[i] + 999) / 1000;
        ll z = std::min(m / 10, Z);
        Z -= z;
        m -= z * 10LL;
        v.push_back(m);
    }
    sort(v.begin(), v.end(), greater<ll>());
    REP(i, N) {
        ll m = v[i];
        ll z = std::min((m + 9) / 10, Z);
        Z -= z;
        m = std::max(0LL, m - z * 10);
        v[i] = m;
    }
    REP(i, N) {
        ll m = v[i];
        ll y = std::min(m / 5, Y);
        Y -= y;
        m -= y * 5LL;
        v[i] = m;
    }
    sort(v.begin(), v.end(), greater<ll>());
    REP(i, N) {
        ll m = v[i];
        ll z = std::min((m + 9) / 10, Z);
        Z -= z;
        m = std::max(0LL, m - z * 10);
        ll y = std::min((m + 4) / 5, Y);
        Y -= y;
        m = std::max(0LL, m - y * 5);
        ll x = std::min(X, m);
        X -= x;
        m -= x;
        if (m > 0)
            return false;
    }

    return true;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    cin >> N >> X >> Y >> Z;
    REP(i, N) {
        cin >> A[i];
        if (A[i] % 1000 == 0)
            A[i]++;
    }
    if (check())
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}
0