結果

問題 No.1015 おつりは要らないです
ユーザー sugarrr
提出日時 2020-04-03 21:55:29
言語 C++17(clang)
(17.0.6 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 2,297 bytes
コンパイル時間 2,265 ms
コンパイル使用メモリ 164,952 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-11-30 17:17:36
合計ジャッジ時間 4,067 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 21 WA * 12
権限があれば一括ダウンロードができます

ソースコード

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);

bool comp(ll i,ll j){
    return i%5<j%5;
}
bool comp1(ll i,ll j){
    return i%10<j%!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;
    }
    sort(c,c+n,comp);
    for(ll i=0;i<n && x>0;i++){
        if(c[i]%5==0)continue;
        if(c[i]%5<=x){
            x-=c[i]%5;
            c[i]-=c[i]%5;
        }else{
            break;
        }
    }
    if(x>0){
        y+=x/5;
        for(ll i=0;i<n && y>0;i++){
            if(c[i]%10==5){
                y-=1;
                c[i]-=5;
            }
        }
        z+=y/2;
        ll sum=0;
        rep(i,0,n-1){
            sum+=(c[i]+9)/10;
        }
        if(sum>z){
            cout<<"No"<<endl;
            return 0;
        }else{
            cout<<"Yes"<<endl;
        }
    }else{
        sort(c,c+n,comp1);
        for(ll i=0;i<n && y>0;i++){
            if(c[i]%10==0)continue;
            if(c[i]%10<=y*5){
                if(c[i]%10<=5){
                    y-=1;
                    c[i]-=5;
                }else{
                    y-=2;
                    c[i]-=10;
                }
            }else{
                break;
            }
        }
        z+=y/2;
        ll sum=0;
        rep(i,0,n-1){
            sum+=(c[i]+9)/10;
        }
        if(sum>z){
            cout<<"No"<<endl;
            return 0;
        }else{
            cout<<"Yes"<<endl;
        }
    }
    
    
    return 0;
}
0