結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 1 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 48 ms
4,376 KB
testcase_11 AC 50 ms
4,380 KB
testcase_12 AC 47 ms
4,376 KB
testcase_13 AC 49 ms
4,376 KB
testcase_14 AC 51 ms
4,380 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 44 ms
4,376 KB
testcase_21 AC 43 ms
4,376 KB
testcase_22 AC 43 ms
4,376 KB
testcase_23 AC 42 ms
4,376 KB
testcase_24 AC 44 ms
4,376 KB
testcase_25 AC 43 ms
4,376 KB
testcase_26 AC 43 ms
4,380 KB
testcase_27 AC 43 ms
4,380 KB
testcase_28 AC 43 ms
4,376 KB
testcase_29 AC 43 ms
4,380 KB
testcase_30 AC 2 ms
4,376 KB
testcase_31 AC 19 ms
4,376 KB
testcase_32 AC 19 ms
4,376 KB
testcase_33 AC 42 ms
4,376 KB
testcase_34 AC 2 ms
4,376 KB
testcase_35 AC 2 ms
4,376 KB
testcase_36 AC 1 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];
        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;
        if(2*sum<=y){
            y-=2*sum;
        }
        else{
            ll tmp = y/2;
            y-=tmp;
            sum-=2*tmp;
            if(10*sum<=x)x-=10*sum;
            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+=1;
            a[i]-=5000;
        }
    }
    if(sum<=y)y-=sum;
    else{
        sum-=y;
        y=0;
        if(5*sum<=x){
            x-=5*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