結果

問題 No.1015 おつりは要らないです
ユーザー hanbei_dayohanbei_dayo
提出日時 2020-04-04 00:27:35
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,535 bytes
コンパイル時間 801 ms
コンパイル使用メモリ 88,612 KB
実行使用メモリ 4,500 KB
最終ジャッジ日時 2023-09-16 05:08:05
合計ジャッジ時間 3,638 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 56 ms
4,376 KB
testcase_16 AC 58 ms
4,376 KB
testcase_17 AC 58 ms
4,376 KB
testcase_18 AC 56 ms
4,376 KB
testcase_19 AC 56 ms
4,380 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 1 ms
4,380 KB
testcase_31 AC 23 ms
4,380 KB
testcase_32 WA -
testcase_33 AC 49 ms
4,376 KB
testcase_34 AC 2 ms
4,380 KB
testcase_35 WA -
testcase_36 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<functional>
#include<math.h>
using namespace std;
#define N (1000000000+7)
#define M (998244353)
#define INF 1e16
typedef long long ll;
typedef pair<int,ll> P;

ll d[32][32];
ll now[510][510];
ll r[3]={0,1,2};

ll cost[5][35];

int main(){
    ll n,x,y,z;
    cin>>n>>x>>y>>z;
    vector<ll>a(n);
    ll sum = 0;
    for(ll i=0;i<n;i++){
        cin>>a[i];
    }
    sort(a.begin(),a.end(),greater<ll>());
    for(ll i=0;i<n;i++){
        if(z==0)break;
        else{
            if(a[i]>=10000){
                ll k = a[i]/10000;
                if(z>=k){
                    z-=k;
                    a[i]-=10000*k;
                }
                else{
                    z=0;
                    a[i]-=10000*z;
                }
            }
            else{
                a[i]-=10000;
                z--;
            }
        }
    }
    sort(a.begin(),a.end(),greater<ll>());
    for(ll i=0;i<n;i++){
        if(z==0)break;
        if(a[i]>=0){
            a[i]-=10000;
            z--;
        }
    }
    sort(a.begin(),a.end(),greater<ll>());
    for(ll i=0;i<n;i++){
        if(y==0)continue;
        else{
            if(a[i]>=5000){
                ll k = a[i]/5000;
                if(y>=k){
                    y-=k;
                    a[i]-=5000*k;
                }
                else{
                    y=0;
                    a[i]-=5000*z;
                }
            }
            else{
                if(a[i]<0)continue;
                a[i]-=5000;
                y--;
            }
        }
    }
    sort(a.begin(),a.end(),greater<ll>());
    for(ll i=0;i<n;i++){
        if(y==0)break;
        if(a[i]>=0){
            a[i]-=5000;
            y--;
        }
    }
    sort(a.begin(),a.end(),greater<ll>());
    for(ll i=0;i<n;i++){
        if(a[i]<0)continue;
        if(x==0)continue;
        else{
            if(a[i]>=1000){
                ll k = a[i]/1000+1;
                if(y>=k){
                    y-=k;
                    a[i]-=1000*k;
                }
                else{
                    y=0;
                    a[i]-=1000*z;
                }
            }
            else{
                a[i]-=1000;
                y--;
            }
        }
    }
    for(ll i=0;i<n;i++){
        if(a[i]>=0){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}
0