結果

問題 No.1015 おつりは要らないです
ユーザー kappybarkappybar
提出日時 2020-04-03 22:09:41
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 72 ms / 2,000 ms
コード長 2,292 bytes
コンパイル時間 2,034 ms
コンパイル使用メモリ 170,352 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-11 08:42:18
合計ジャッジ時間 4,751 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const ll INF = 1e18;
const int MOD = 1000000007;

int main(){
        int n,x,y,z;
        cin >> n >> z >> y >> x;
        priority_queue<int> pq;
        bool ok = true;
        rep(i,n){
                int a;
                cin >> a;
                a++;
                pq.push(a);
        }

        while(x > 0 && !pq.empty()){
                int p = pq.top();
                pq.pop();
                if(p < 10000){
                        x--;
                }else{
                        if(x >= p/10000){
                                x -= p/10000;
                                p %= 10000;
                                if(p!=0) pq.push(p);
                        }else{
                                p -= x*10000;
                                x = 0;
                                if(p!=0) pq.push(p);
                        }
                }
        }

        while(y > 0 && !pq.empty()){
                int p = pq.top();
                pq.pop();
                if(p < 5000){
                        y--;
                }else{
                        if(y >= p/5000){
                                y -= p/5000;
                                p %= 5000;
                                if(p!=0) pq.push(p);
                        }else{
                                p -= y*5000;
                                y = 0;
                                if(p!=0) pq.push(p);
                        }
                }
        }

        while(z > 0 && !pq.empty()){
                int p = pq.top();
                pq.pop();
                if(p < 1000){
                        z--;
                }else{
                        if(z >= p/1000){
                                z -= p/1000;
                                p %= 1000;
                                if(p!=0)pq.push(p);
                        }else{
                                p -= z*1000;
                                z = 0;
                                if(p!=0)pq.push(p);
                        }
                }
        }



        if(pq.empty()) cout << "Yes" << endl;
        else cout << "No" << endl;
        return 0;
}




0