結果

問題 No.1015 おつりは要らないです
ユーザー curi_ku
提出日時 2020-04-06 11:28:11
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 1,606 bytes
コンパイル時間 1,579 ms
コンパイル使用メモリ 172,412 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-07-05 23:15:43
合計ジャッジ時間 4,340 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3 WA * 1
other AC * 18 WA * 15
権限があれば一括ダウンロードができます

ソースコード

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){
        ll b = a[i];
        ll c = b/1000;
        int d =b%1000;
        if(d!=0||d==0){
            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){
                    cout<<"No"<<endl;
                    flag=false;
                }
                else{
                    x-=c;
                    c=0;
                }
            }
            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