結果

問題 No.1015 おつりは要らないです
ユーザー rok_dwrok_dw
提出日時 2020-04-19 18:02:11
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,746 bytes
コンパイル時間 1,935 ms
コンパイル使用メモリ 165,756 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-15 19:04:38
合計ジャッジ時間 4,353 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG2(x,y) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define DEBUG_ARR(v,n) cout<<#v<<":";REP(i,n)cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    int n,x,y,z;
    cin>>n>>x>>y>>z;
    vi a(n);

    REP(i,n) {
        cin>>a[i];
    }

    REP(i,n){
        //DEBUG(x);
        //DEBUG(y);
        //DEBUG(z);
        int xx,yy,zz;
        int usex=0, usey=0;

        //DEBUG(a[i]);

        if(z > 0){
            zz = min(z,(a[i]/10000));
            a[i] -= zz*10000;
            z -= zz;
        }
        
        if(y > 0){
            yy = min(y,(a[i]/5000));
            a[i] -= yy*5000;
            y -= yy;
            usey += yy;
        }

        if(x > 0){
            xx = min(x,(a[i]/1000));
            if(xx*1000 > a[i]){
                a[i] -= xx*1000;
                x -= xx;
                usex += xx;
            }
        }

        if(a[i]>=0){
            if(a[i]>=0 && x>0){
                xx = min(x,(a[i]/1000)+1);
                a[i] -= xx*1000;
                x -= xx;
                usex += xx;
            }

            if(y>0){
                yy = min(y,(a[i]/5000)+1);
                a[i] -= yy*5000;
                y -= yy;
                usey += yy;
            }

            if(a[i]>=0 && z>0){
                zz = min(z,(a[i]/10000)+1);
                a[i] -= zz*10000;
                z -= zz;
            }

            if(usey > 0 && ((a[i]/-5000) > 0)){
                yy = min(usey,(a[i]/-5000));
                if(a[i] == -yy*5000) yy--;
                a[i] += yy*5000;
                y += yy;
            }


            if(usex > 0 && ((a[i]/-1000) > 0)){
                xx = min(usex,(a[i]/-1000));
                if(a[i] == -xx*1000) xx--;
                a[i] += xx*1000;
                x += xx;
            }
        }

        if(a[i]>=0 && x>0){
            xx = min(x,(a[i]/1000)+1);
            a[i] -= xx*1000;
            x -= xx;
        }

        //a[i]==0は釣りがないのでだめ
        if(a[i]>=0){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}
0