結果

問題 No.1015 おつりは要らないです
ユーザー ゆきのんゆきのん
提出日時 2020-04-15 17:45:25
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 74 ms / 2,000 ms
コード長 2,217 bytes
コンパイル時間 2,022 ms
コンパイル使用メモリ 172,564 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-11 13:50:58
合計ジャッジ時間 4,941 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
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; }
template<typename T> T gcd(T a,T b){return b?gcd(b,a%b):a;}
const LL mod=1000000007;
const LL LINF=1LL<<62;
const int INF=1<<30;
int dx[]={1,0,-1,0,1,-1,1,-1};
int dy[]={0,1,0,-1,1,-1,-1,1};

bool solve(){
    int n;cin >> n;
    vector<LL> x(3,0);
    cin >> x[0] >> x[1] >> x[2];
    priority_queue<LL> pq;
    for (int i = 0; i < n; i++) {
        LL a;cin >> a;
        pq.push(a);
    }
    while(not pq.empty()){
        if(x[2]){
            LL t = pq.top();pq.pop();
            LL c = t / 10000;
            if(c == 0) c = 1;
            if(c <= x[2]){
                x[2] -= c;
                t -= 10000 * c;
                if(t >= 0) pq.push(t);
            }
            else{
                t -= 10000 * x[2];
                x[2] = 0;
                if(t >= 0) pq.push(t);
            }
        }
        else if(x[1]){
            LL t = pq.top();pq.pop();
            LL c = t / 5000;
            if(c == 0) c = 1;
            if(c <= x[1]){
                x[1] -= c;
                t -= 5000 * c;
                if(t >= 0) pq.push(t);
            }
            else{
                t -= 5000 * x[1];
                x[1] = 0;
                if(t >= 0) pq.push(t);
            }
        }
        else if(x[0]){
            LL t = pq.top();pq.pop();
            LL c = t / 1000;
            if(c == 0) c = 1;
            if(c <= x[0]){
                x[0] -= c;
                t -= 1000 * c;
                if(t >= 0) pq.push(t);
            }
            else{
                t -= 1000 * x[0];
                x[0] = 0;
                if(t >= 0) pq.push(t);
            }
        }
        else{
            return false;
        }
    }
    return true;
}



int main(){
    if(solve()) puts("Yes");
    else puts("No");
    return 0;
}

0