結果

問題 No.1015 おつりは要らないです
ユーザー ShibuyapShibuyap
提出日時 2020-07-21 23:22:58
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 46 ms / 2,000 ms
コード長 2,304 bytes
コンパイル時間 2,143 ms
コンパイル使用メモリ 203,652 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-29 06:17:28
合計ジャッジ時間 4,248 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 AC 2 ms
5,376 KB
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 40 ms
5,376 KB
testcase_11 AC 41 ms
5,376 KB
testcase_12 AC 38 ms
5,376 KB
testcase_13 AC 40 ms
5,376 KB
testcase_14 AC 42 ms
5,376 KB
testcase_15 AC 39 ms
5,376 KB
testcase_16 AC 40 ms
5,376 KB
testcase_17 AC 41 ms
5,376 KB
testcase_18 AC 40 ms
5,376 KB
testcase_19 AC 39 ms
5,376 KB
testcase_20 AC 38 ms
5,376 KB
testcase_21 AC 38 ms
5,376 KB
testcase_22 AC 37 ms
5,376 KB
testcase_23 AC 37 ms
5,376 KB
testcase_24 AC 38 ms
5,376 KB
testcase_25 AC 37 ms
5,376 KB
testcase_26 AC 37 ms
5,376 KB
testcase_27 AC 37 ms
5,376 KB
testcase_28 AC 36 ms
5,376 KB
testcase_29 AC 37 ms
5,376 KB
testcase_30 AC 2 ms
5,376 KB
testcase_31 AC 17 ms
5,376 KB
testcase_32 AC 17 ms
5,376 KB
testcase_33 AC 46 ms
5,376 KB
testcase_34 AC 2 ms
5,376 KB
testcase_35 AC 2 ms
5,376 KB
testcase_36 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

int main() {
    ll n, x, y, z;
    cin >> n >> x >> y >> z;
    ll a[n];
    rep(i,n)cin >> a[i];
    rep(i,n){
        a[i] = a[i] / 1000 + 1;
        while(a[i] >= 10){
            if(z > 0){
                int aa = a[i] / 10;
                if(z >= aa){
                    a[i] -= aa * 10;
                    z -= aa;
                }else{
                    a[i] -= z * 10;
                    z = 0;
                }
            }else if(y > 0){
                int aa = a[i] / 10;
                int yy = y / 2;
                if(yy >= aa){
                    a[i] -= aa * 10;
                    y -= aa * 2;
                }else{
                    a[i] -= yy * 10;
                    y -= yy * 2;
                }
                if(y == 1 && a[i] >= 5){
                    a[i] -= 5;
                    y--;
                }
            }else if(x > 0){
                if(x >= a[i]){
                    x -= a[i];
                    a[i] = 0;
                }else{
                    a[i] -= x;
                    x = 0;
                }
            }else if(a[i] >= 10){
                cout << "No" << endl;
                return 0;
            }
        }
    }
    
    int cnt[10] = {};
    rep(i,n){
        cnt[a[i]]++;
    }

    drep(i,10){
        while(cnt[i]--){
            int aa = i;
            if(z > 0){
                z--;
                aa = 0;
            }
            if(aa == 0)continue;
            if(y > 0){
                y--;
                aa = max(aa-5, 0);
                cnt[aa]++;
                aa = 0;
            }
            if(aa == 0) continue;
            if(x > 0){
                if(aa > x){
                    cout << "No" << endl;
                    return 0;
                }
                x -= aa;
                aa = 0;
            }
            if(aa > 0){
                cout << "No" << endl;
                return 0;
            }
        }
    }

    cout << "Yes" << endl;
    return 0;
}
 
 
0