結果

問題 No.1015 おつりは要らないです
ユーザー IKyoproIKyopro
提出日時 2020-04-03 23:14:43
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 987 bytes
コンパイル時間 2,058 ms
コンパイル使用メモリ 201,552 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-09-16 04:34:17
合計ジャッジ時間 3,999 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T, class U> using Pa = pair<T, U>;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    vec<int> X(3);
    cin >> N >> X[0] >> X[1] >> X[2];
    vec<int> B = {1000,5000,10000};
    vec<int> A(N);
    bool ok = true;
    for(int i=0;i<N;i++){
        int a;
        cin >> a;
        for(int j=2;j>=0;j--){
            if(B[j]>=a){
                int n  = min(a/B[j],X[j]);
                a -= n*B[j];
                X[j] -= n;
            }
            if(j!=0 && B[j]>0 && B[j]>a && a>B[j-1]){
                B[j]--;
                a = -1;
            }
        }
        if(a==-1){
            for(int j=0;j<3;j++) if(X[j]){
                X[j]--;
                a = -1;
                break;
            }
        }
        ok &= a==-1;
    }
    cout << (ok? "Yes\n":"No\n");
}
0