結果

問題 No.1015 おつりは要らないです
ユーザー curi_kucuri_ku
提出日時 2020-04-06 11:34:09
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,107 bytes
コンパイル時間 1,513 ms
コンパイル使用メモリ 170,984 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-09-20 03:11:15
合計ジャッジ時間 4,281 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
typedef long long ll;
typedef pair<ll,ll> pint;
int main(){
    ll n,x,y,z;
    cin>>n>>x>>y>>z;
    vector<ll> a(n);rep(i,n)cin>>a[i];
    sort(a.begin(),a.end());
    bool flag=true;
    rep(i,n){
        bool flag1=false;
        ll b = a[i];
        ll c = b/1000;
        int d =b%1000;
        if(d!=0||d==0){
            //cout<<x<<y<<z<<endl;
            if(10<=c&&0<z){
                int b1=c/10;
                if(z<b1){
                    c=c-10*z;
                    z=0;
                }
                else{
                    z-=b1;
                    c=c-10*b1;
                }
            }
            if(5<=c&&0<y){
                int b2=c/5;
                if(y<b2){
                    c=c-5*y;
                    y=0;
                }
                else{
                    y-=b2;
                    c=c-5*b2;
                }
            }
            if(0<=c&&0<x){
                int b3=c;
                if(x<b3){
                    if(0<y){
                        c=0;
                        y-=1;
                        flag1=true;
                    }
                    else if(0<z){
                        c=0;
                        z-=1;
                        flag1=true;
                    }
                    else{
                    cout<<"No"<<endl;
                    flag=false;
                    }
                }
                else{
                    x-=c;
                    c=0;
                }
            }
            if(flag1=false){
                if(0<x){
                    x-=1;
                }
                else if(0<y){
                    y-=1;
                }
                else if(0<z){
                    z-=1;
                }
                else{
                    cout<<"No"<<endl;
                    flag=false;
                }
            }
        }
        }
    if(flag){
        cout<<"Yes"<<endl;
        //cout<<x<<y<<z<<endl;
    }
}
0