結果

問題 No.1015 おつりは要らないです
ユーザー outlineoutline
提出日時 2020-04-03 22:01:48
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,472 bytes
コンパイル時間 1,144 ms
コンパイル使用メモリ 115,620 KB
実行使用メモリ 4,500 KB
最終ジャッジ日時 2023-09-16 01:36:27
合計ジャッジ時間 3,271 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 1 ms
4,380 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 25 ms
4,376 KB
testcase_16 AC 25 ms
4,376 KB
testcase_17 AC 26 ms
4,380 KB
testcase_18 AC 25 ms
4,376 KB
testcase_19 AC 25 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 2 ms
4,376 KB
testcase_31 AC 11 ms
4,376 KB
testcase_32 AC 11 ms
4,376 KB
testcase_33 AC 16 ms
4,376 KB
testcase_34 WA -
testcase_35 AC 1 ms
4,376 KB
testcase_36 AC 2 ms
4,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;
        }
    }

    sort(a.begin(), a.end());
    for(int i = 0; i < n; ++i){
        if(a[i] == 0){
            if(x > 0){
                --x;
                continue;
            }
            if(y > 0){
                --y;
                continue;
            }
            if(z > 0){
                --z;
                continue;
            }
        }
        else{
            int 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