結果

問題 No.1015 おつりは要らないです
ユーザー sugarrrsugarrr
提出日時 2020-04-03 22:42:06
言語 C++17(clang)
(17.0.6 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,812 bytes
コンパイル時間 2,352 ms
コンパイル使用メモリ 164,708 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-05-07 21:03:45
合計ジャッジ時間 3,717 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_ll.hpp>
//typedef boost::multiprecision::cpp_ll ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
string alp="abcdefghijklmnopqrstuvwxyz";
#define endl "\n"
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);


int main(){fastio
    ll n,x,y,z;cin>>n>>x>>y>>z;
    ll a[n];rep(i,0,n-1)cin>>a[i];
    ll c[n];
    rep(i,0,n-1){
        c[i]=(a[i])/1000+1;
    }
    for(ll i=0;i<n && z>0;i++){
        if(z>=c[i]/10){
            z-=c[i]/10;
            c[i]-=(c[i]/10)*10;
        }else{
            c[i]-=z*10;
            z=0;
        }
    }
    for(ll i=0;i<n && y>0;i++){
        if(y>=c[i]/5){
            y-=c[i]/5;
            c[i]-=(c[i]/5)*5;
        }else{
            c[i]-=y*5;
            y=0;
        }
    }
    if(y==0 && z==0){
        ll sum=0;
        rep(i,0,n-1)sum+=c[i];
        if(sum>x){
            cout<<"No"<<endl;
        }else{
            cout<<"Yes"<<endl;
        }
    }else if(y!=0 && z==0){
        sort(c,c+n);
        rep(i,0,n-1){
            if(x>=c[i]){
                x-=c[i];
                c[i]=0;
            }else{
                break;
            }
        }
        ll sum=0;
        rep(i,0,n-1){
            if(c[i]!=0){
                sum++;
            }
        }
        if(sum>y){
            cout<<"No"<<endl;
        }else{
            cout<<"Yes"<<endl;
        }
    }else if(y==0 && z!=0){
        sort(c,c+n);
        rep(i,0,n-1){
            if(x>=c[i]){
                x-=c[i];
                c[i]=0;
            }else{
                break;
            }
        }
        ll sum=0;
        rep(i,0,n-1){
            if(c[i]!=0){
                sum++;
            }
        }
        if(sum>z){
            cout<<"No"<<endl;
        }else{
            cout<<"Yes"<<endl;
        }
    }else{
        sort(c,c+n);
        rep(i,0,n-1){
            if(x>=c[i]){
                x-=c[i];
                c[i]=0;
            }else{
                break;
            }
        }
        ll sum=0;
        rep(i,0,n-1){
            if(c[i]!=0){
                sum++;
            }
        }
        if(sum>z+y){
            cout<<"No"<<endl;
        }else{
            cout<<"Yes"<<endl;
        }
    }
    
    
    
    return 0;
}
0