結果

問題 No.1015 おつりは要らないです
ユーザー outlineoutline
提出日時 2020-04-03 22:38:24
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 11,924 bytes
コンパイル時間 1,430 ms
コンパイル使用メモリ 115,648 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-07-03 04:53:51
合計ジャッジ時間 3,111 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 WA -
testcase_06 WA -
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 22 ms
5,376 KB
testcase_11 AC 22 ms
5,376 KB
testcase_12 AC 21 ms
5,376 KB
testcase_13 AC 21 ms
5,376 KB
testcase_14 AC 22 ms
5,376 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
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 2 ms
5,376 KB
testcase_31 AC 10 ms
5,376 KB
testcase_32 AC 10 ms
5,376 KB
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

typedef long long ll;
typedef uint64_t ull;
typedef pair<int, int> P;
typedef pair<int, double> Pid;
typedef pair<double, int> Pdi;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
typedef pair<int, pair<int, int>> PP;
typedef pair<P, int> PPi;
constexpr double PI = 3.1415926535897932;   // acos(-1)
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define chadd(x, y) x = (x + y) % mod

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int n;
    int x, y, z;
    cin >> n >> x >> y >> z;
    vector<int> a(n);
    for(int i = 0; i < n; ++i)  cin >> a[i];
    sort(a.begin(), a.end(), greater<int>());
    for(int i = 0; i < n; ++i){
        int need = a[i] / 10000;
        if(need <= z){
            a[i] -= need * 10000;
            z -= need;
            
            need = a[i] / 5000;
            if(need <= y){
                a[i] -= need * 5000;
                y -= need;
                
                need = a[i] / 1000;
                if(need <= x){
                    a[i] -= need * 1000;
                    x -= need;

                    if(a[i] == 0){
                        if(x > 0){
                            --x;
                            continue;
                        }
                        if(y > 0){
                            --y;
                            continue;
                        }
                        if(z > 0){
                            --z;
                            continue;
                        }
                    }
                    else{
                        need = ceil((double)a[i] / 1000);
                        if(need <= x){
                            x -= need;
                            continue;
                        }
                        need = ceil((double)a[i] / 5000);
                        if(need <= y){
                            y -= need;
                            continue;
                        }
                        need = ceil((double)a[i] / 10000);
                        if(need <= z){
                            z -= need;
                            continue;
                        }
                    }
                }
                else{
                    a[i] -= x * 1000;
                    x = 0;
                    
                    if(a[i] == 0){
                        if(x > 0){
                            --x;
                            continue;
                        }
                        if(y > 0){
                            --y;
                            continue;
                        }
                        if(z > 0){
                            --z;
                            continue;
                        }
                    }
                    else{
                        need = ceil((double)a[i] / 1000);
                        if(need <= x){
                            x -= need;
                            continue;
                        }
                        need = ceil((double)a[i] / 5000);
                        if(need <= y){
                            y -= need;
                            continue;
                        }
                        need = ceil((double)a[i] / 10000);
                        if(need <= z){
                            z -= need;
                            continue;
                        }
                    }
                }
            }

            else{
                a[i] -= y * 5000;
                y = 0;

                need = a[i] / 1000;
                if(need <= x){
                    a[i] -= need * 1000;
                    x -= need;

                    if(a[i] == 0){
                        if(x > 0){
                            --x;
                            continue;
                        }
                        if(y > 0){
                            --y;
                            continue;
                        }
                        if(z > 0){
                            --z;
                            continue;
                        }
                    }
                    else{
                        need = ceil((double)a[i] / 1000);
                        if(need <= x){
                            x -= need;
                            continue;
                        }
                        need = ceil((double)a[i] / 5000);
                        if(need <= y){
                            y -= need;
                            continue;
                        }
                        need = ceil((double)a[i] / 10000);
                        if(need <= z){
                            z -= need;
                            continue;
                        }
                    }
                }

                else{
                    a[i] -= x * 1000;
                    x -= need;
                    
                    if(a[i] == 0){
                        if(x > 0){
                            --x;
                            continue;
                        }
                        if(y > 0){
                            --y;
                            continue;
                        }
                        if(z > 0){
                            --z;
                            continue;
                        }
                    }
                    else{
                        need = ceil((double)a[i] / 1000);
                        if(need <= x){
                            x -= need;
                            continue;
                        }
                        need = ceil((double)a[i] / 5000);
                        if(need <= y){
                            y -= need;
                            continue;
                        }
                        need = ceil((double)a[i] / 10000);
                        if(need <= z){
                            z -= need;
                            continue;
                        }
                    }
                }
            }
        }

        else{
            a[i] -= z * 10000;
            z = 0;
            need = a[i] / 5000;
            if(need <= y){
                a[i] -= need * 5000;
                y -= need;
                
                need = a[i] / 1000;
                if(need <= x){
                    a[i] -= need * 1000;
                    x -= need;

                    if(a[i] == 0){
                        if(x > 0){
                            --x;
                            continue;
                        }
                        if(y > 0){
                            --y;
                            continue;
                        }
                        if(z > 0){
                            --z;
                            continue;
                        }
                    }
                    else{
                        need = ceil((double)a[i] / 1000);
                        if(need <= x){
                            x -= need;
                            continue;
                        }
                        need = ceil((double)a[i] / 5000);
                        if(need <= y){
                            y -= need;
                            continue;
                        }
                        need = ceil((double)a[i] / 10000);
                        if(need <= z){
                            z -= need;
                            continue;
                        }
                    }
                }
                else{
                    a[i] -= x * 1000;
                    x = 0;

                    if(a[i] == 0){
                        if(x > 0){
                            --x;
                            continue;
                        }
                        if(y > 0){
                            --y;
                            continue;
                        }
                        if(z > 0){
                            --z;
                            continue;
                        }
                    }
                    else{
                        need = ceil((double)a[i] / 1000);
                        if(need <= x){
                            x -= need;
                            continue;
                        }
                        need = ceil((double)a[i] / 5000);
                        if(need <= y){
                            y -= need;
                            continue;
                        }
                        need = ceil((double)a[i] / 10000);
                        if(need <= z){
                            z -= need;
                            continue;
                        }
                    }
                }
            }
            else{
                a[i] -= y * 5000;
                y -= need;
                need = a[i] / 1000;
                if(need <= x){
                    a[i] -= need * 1000;
                    x -= need;

                    if(a[i] == 0){
                        if(x > 0){
                            --x;
                            continue;
                        }
                        if(y > 0){
                            --y;
                            continue;
                        }
                        if(z > 0){
                            --z;
                            continue;
                        }
                    }
                    else{
                        need = ceil((double)a[i] / 1000);
                        if(need <= x){
                            x -= need;
                            continue;
                        }
                        need = ceil((double)a[i] / 5000);
                        if(need <= y){
                            y -= need;
                            continue;
                        }
                        need = ceil((double)a[i] / 10000);
                        if(need <= z){
                            z -= need;
                            continue;
                        }
                    }
                }
                else{
                    a[i] -= x * 1000;
                    x = 0;

                    if(a[i] == 0){
                        if(x > 0){
                            --x;
                            continue;
                        }
                        if(y > 0){
                            --y;
                            continue;
                        }
                        if(z > 0){
                            --z;
                            continue;
                        }
                    }
                    else{
                        need = ceil((double)a[i] / 1000);
                        if(need <= x){
                            x -= need;
                            continue;
                        }
                        need = ceil((double)a[i] / 5000);
                        if(need <= y){
                            y -= need;
                            continue;
                        }
                        need = ceil((double)a[i] / 10000);
                        if(need <= z){
                            z -= need;
                            continue;
                        }
                    }
                }
            }
        }

        cout << "No\n";
        return 0;
    }

    cout << "Yes\n";
}
0