結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 49 ms
4,376 KB
testcase_11 AC 50 ms
4,376 KB
testcase_12 AC 46 ms
4,380 KB
testcase_13 AC 49 ms
4,376 KB
testcase_14 AC 51 ms
4,376 KB
testcase_15 AC 47 ms
4,376 KB
testcase_16 WA -
testcase_17 AC 49 ms
4,380 KB
testcase_18 AC 50 ms
4,376 KB
testcase_19 WA -
testcase_20 AC 45 ms
4,380 KB
testcase_21 AC 43 ms
4,380 KB
testcase_22 AC 43 ms
4,376 KB
testcase_23 AC 41 ms
4,376 KB
testcase_24 AC 44 ms
4,380 KB
testcase_25 AC 43 ms
4,380 KB
testcase_26 AC 43 ms
4,376 KB
testcase_27 AC 43 ms
4,380 KB
testcase_28 AC 43 ms
4,380 KB
testcase_29 AC 43 ms
4,380 KB
testcase_30 AC 1 ms
4,380 KB
testcase_31 AC 18 ms
4,376 KB
testcase_32 AC 18 ms
4,380 KB
testcase_33 AC 42 ms
4,376 KB
testcase_34 AC 2 ms
4,376 KB
testcase_35 AC 2 ms
4,380 KB
testcase_36 AC 2 ms
4,376 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];
        if(a[i]>=10000){
            ll t = a[i]/10000;
            sum+=t;
            a[i]-=t*10000;
        }
    }
    if(sum<=z)z-=sum;
    else{
        sum-=z;
        z=0;
        sum = 2*sum;
        if(sum<=y){
            y-=sum;
        }
        else{
            if(y%2==0){
                sum-=y;
                y=0;
                sum = 5*sum;
                if(sum<=x)x-=sum;
                else{
                    cout<<"No"<<endl;
                    return 0;
                }
            }
            else{
                sum-=(y-1);
                y=1;
                if(x>=5){
                    y=0;
                    x-=5;
                    sum-=2;
                }
                else{
                    cout<<"No"<<endl;
                    return 0;
                }
            }
        }
    }
    sort(a.begin(),a.end(),greater<ll>());
    for(ll i=0;i<n;i++){
        if(z>0){
            z--;
            a[i]-=10000;
            continue;
        }
        else break;
    }
    sum = 0;
    for(ll i=0;i<n;i++){
        if(a[i]>=5000){
            sum++;
            a[i]-=5000;
        }
    }
    if(sum<=y)y-=sum;
    else{
        sum-=y;
        y=0;
        sum = 5*sum;
        if(sum<=x){
            x-=sum;
        }
        else{
            cout<<"No"<<endl;
            return 0;
        }
    }
    sort(a.begin(),a.end(),greater<ll>());
    for(ll i=0;i<n;i++){
        if(a[i]<0)continue;
        if(y>0){
            y--;
            continue;
        }
        if(a[i]>=0){
            if(x<=0){
                cout<<"No"<<endl;
                return 0;
            }
            else{
                ll cnt = a[i]/1000;
                cnt++;
                x-=cnt;
                if(x<0){
                    cout<<"No"<<endl;
                    return 0;
                }
            }
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}
0