結果

問題 No.1015 おつりは要らないです
ユーザー IKyopro
提出日時 2020-04-03 23:14:43
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 987 bytes
コンパイル時間 2,364 ms
コンパイル使用メモリ 194,268 KB
最終ジャッジ日時 2025-01-09 13:41:19
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2 WA * 2
other AC * 12 WA * 21
権限があれば一括ダウンロードができます

ソースコード

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