結果

問題 No.1015 おつりは要らないです
ユーザー coco18000coco18000
提出日時 2020-04-03 21:52:52
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,280 bytes
コンパイル時間 1,782 ms
コンパイル使用メモリ 172,936 KB
実行使用メモリ 4,928 KB
最終ジャッジ日時 2023-09-16 01:10:23
合計ジャッジ時間 3,720 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 1 ms
4,384 KB
testcase_10 AC 25 ms
4,744 KB
testcase_11 AC 26 ms
4,780 KB
testcase_12 AC 24 ms
4,880 KB
testcase_13 AC 25 ms
4,764 KB
testcase_14 AC 26 ms
4,876 KB
testcase_15 AC 24 ms
4,816 KB
testcase_16 AC 25 ms
4,892 KB
testcase_17 AC 26 ms
4,824 KB
testcase_18 AC 25 ms
4,912 KB
testcase_19 AC 25 ms
4,756 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 AC 2 ms
4,380 KB
testcase_31 AC 12 ms
4,916 KB
testcase_32 AC 13 ms
4,684 KB
testcase_33 AC 19 ms
4,672 KB
testcase_34 AC 1 ms
4,380 KB
testcase_35 AC 2 ms
4,376 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;
        ll y = std::min(m / 5, Y);
        Y -= y;
        m -= y * 5LL;
        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);
        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