結果

問題 No.1015 おつりは要らないです
ユーザー hirono999hirono999
提出日時 2020-04-03 22:11:33
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,904 bytes
コンパイル時間 1,623 ms
コンパイル使用メモリ 169,988 KB
実行使用メモリ 4,568 KB
最終ジャッジ日時 2023-09-16 02:05:51
合計ジャッジ時間 4,124 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 37 ms
4,380 KB
testcase_11 AC 38 ms
4,380 KB
testcase_12 AC 36 ms
4,380 KB
testcase_13 AC 37 ms
4,376 KB
testcase_14 AC 39 ms
4,376 KB
testcase_15 AC 36 ms
4,376 KB
testcase_16 AC 37 ms
4,380 KB
testcase_17 AC 38 ms
4,376 KB
testcase_18 AC 36 ms
4,384 KB
testcase_19 AC 36 ms
4,376 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 1 ms
4,376 KB
testcase_31 AC 12 ms
4,380 KB
testcase_32 AC 13 ms
4,376 KB
testcase_33 AC 17 ms
4,376 KB
testcase_34 WA -
testcase_35 WA -
testcase_36 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep1(i, n) for (ll i = 1; i <= (n); ++i)
#define rrep(i, n) for (ll i = (n - 1); i >= 0; --i)
#define perm(c) sort(ALL(c));for(bool c##p=1;c##p;c##p=next_permutation(ALL(c)))
#define ALL(obj) (obj).begin(), (obj).end()
#define pb push_back
#define to_s to_string
#define len(v) (ll)v.size()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define print(x) cout << (x) << '\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
using namespace std;
using ll = long long;
typedef pair<ll, ll> P;
typedef vector<ll> vec;
typedef vector<vector<ll>> vec2;
typedef vector<vector<vector<ll>>> vec3;
ll MOD = 1e9 + 7;
ll devc(ll x, ll y) { return 1 + (x - 1) / y; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);

    ll N, X, Y, Z;
    cin >> N >> X >> Y >> Z;
    priority_queue<ll> A;
    rep(i, N){
        ll a;
        cin >> a;
        a = (a / 1000 + 1) * 1000;
        A.push(a);
    }
    
    while(!A.empty()){
        ll now = A.top();
        A.pop();

        ll tpx = X;
        if(now > 10000){
            Z -= now / 10000;
            now %= 10000;
        }else if(now > 5000){
            Y -= now / 5000;
            now %= 5000;
        }else{
            X -= now / 1000;
            now %= 1000;
        }

        if(Z < 0) Y -= abs(Z) * 2, Z = 0;
        if(Y < 0) X -= abs(Y) * 5, Y = 0;
        if(X < 0){
            if(Y > 0) --Y, X = tpx;
            else if(Z > 0) --Z, X = tpx;
            else{
                print("No");
                return 0;
            }
        }

        if(now != 0) A.push(now);
    }

    
    print("Yes");

    return 0;
}
0