結果

問題 No.1015 おつりは要らないです
ユーザー konaaiocxvmq982konaaiocxvmq982
提出日時 2020-04-03 21:57:05
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 3,389 bytes
コンパイル時間 1,796 ms
コンパイル使用メモリ 170,228 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-16 01:21:14
合計ジャッジ時間 4,152 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;

template<typename T>
using priority_queue_rev = priority_queue<T, vector<T>, greater<T> >;

static const int INTINF = (2147483647 >> 1); // 10^9 + 5000
static const ll LLINF = (9223372036854775807 >> 1);
static const int MAX = 1e5+1;
static const ll MOD = 1e9+7;

namespace Kunitaka{
    template<
        typename TYPE,
        std::size_t SIZE
    >
    std::size_t array_length(const TYPE (&array)[SIZE])
    {
        return SIZE;
    }

    template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
    template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
}
using namespace Kunitaka;
namespace Printer{
    void br(){
        cout << endl;
    }

    void loop_cnt(int i){
        cout << "i = " << i << endl;
    }

    void loop_cnt(int i, int j){
        cout << "i = " << i << ", " << "j = " << j << endl;
    }

    template<class T>
    void print(T x){
        cout << x << endl;
    }

    template<class T, class S>
    void print(T x, S y){
        cout << x << "," << y << endl;
    }

    template<class T, class S, class U>
    void print(T x, S y, U z){
        cout << x << "," << y << "," << z << endl;
    }

    template<class T, class S>
    void print(pair<T, S> p){
        cout << p.first << ", " << p.second << endl;
    }

    template<
        typename TYPE,
        std::size_t SIZE
    >
    void print(const TYPE (&array)[SIZE]){
        int lim = array_length(array);
        for(int i=0; i<lim; i++){
            if(i) cout << " ";
            cout << array[i];
        }
        cout << endl;
    }

    template<class S>
    void print(vector<S> v){
        for(int i=0; i<v.size(); i++){
            if(i) cout << " ";
            cout<< v[i];
        }
        cout << endl;
    }

    template<class S>
    void print(vector<vector<S> > vv){
        for(int i=0; i<vv.size(); i++){
            for(int j=0; j<vv[i].size(); j++){
                if(j) cout << " ";
                cout << vv[i][j];
            }
            cout << endl;
        }
    }

    void yesno(bool x){
        if(x) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
};
using namespace Printer;

ll gausu(ll x, ll val){
    ll res = val / x;
    res++;
    return res;
}

int main(int argc, const char * argv[]) {
    //提出時、消す----//
    //--------------//


    // input
    cout << fixed << setprecision(10);
    int N, X, Y, Z; cin >> N >> X >> Y >> Z;
    ll all_cnt = X + Y + Z;
    vector<int> A(N);
    rep(i, N) cin >> A[i];
    sort(ALL(A), greater<int>());
    rep(i, N){
        ll nokori_cnt = all_cnt - i - 1;
        ll cnt1 = gausu(A[i], 1000);
        if(X >= cnt1 && all_cnt - cnt1 >= nokori_cnt){
            X -= cnt1;
            continue;
        }
        ll cnt2 = gausu(A[i], 5000);
        if(Y >= cnt2 && all_cnt - cnt2 >= nokori_cnt){
            Y -= cnt2;
            continue;
        }
        ll cnt3 = gausu(A[i], 10000);
        if(Z >= cnt1 && all_cnt - cnt1 >= nokori_cnt){
            Z -= cnt1;
            continue;
        }

        cout << "No" << endl;
        return 0;
    }

    cout << "Yes" << endl;
    
    
    return 0;
}
0