結果

問題 No.1015 おつりは要らないです
ユーザー hipopohipopo
提出日時 2020-04-10 16:55:14
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,373 bytes
コンパイル時間 1,530 ms
コンパイル使用メモリ 141,336 KB
実行使用メモリ 4,356 KB
最終ジャッジ日時 2023-10-13 08:00:49
合計ジャッジ時間 5,661 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <algorithm>
#include <cmath>
#include <complex>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
#include <functional>
#include <cstring>
#include <regex>
#include <random>
#include <cassert>
#include <stack>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, s, n) for (int i = (s); i < (int)(n); i++)
#define revrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define revrepr(i, s, n) for (int i = (n) - 1; i >= s; i--)
#define debug(x) cerr << #x << ": " << x << "\n"
#define popcnt(x) __builtin_popcount(x)

using ll = long long;
using P = pair<int, int>;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

template<class T>
istream& operator >>(istream &is, vector<T> &v) {
    for (int i = 0; i < (int)v.size(); i++) cin >> v.at(i);
    return is;
}

template<class T, class U>
ostream& operator <<(ostream &os, pair<T, U> p) {
    cout << '(' << p.first << ", " << p.second << ')';
    return os;
}

template<class T>
void print(const vector<T> &v, const string &delimiter) { rep(i, v.size()) cout << (0 < i ? delimiter : "") << v.at(i); cout << endl; }

template<class T>
void print(const vector<vector<T>> &vv, const string &delimiter) { for (const auto &v: vv) print(v, delimiter); }

ll div_ceil(ll x, ll d) { return (x + d - 1) / d; }

int main() {
    int n;
    ll x, y, z;
    cin >> n >> x >> y >> z;
    vector<ll> a(n);
    cin >> a;
    rep(i, n) a[i] = div_ceil(a[i] + 1, 1000) * 1000;
    sort(a.begin(), a.end());
    
    auto pay = [&](ll m){
        ll c10000 = min(z, m / 10000);
        m -= c10000 * 10000;
        z -= c10000;
        if (m <= 0) return true;
        
        ll c5000 = min(y, m / 5000);
        m -= c5000 * 5000;
        y -= c5000;
        if (m <= 0) return true;
        
        if (m <= x * 1000) {
            x -= m / 1000;
            return true;
        }
        if (m <= y * 5000) {
            y--;
            return true;
        }
        if (m <= z * 10000) {
            z--;
            return true;
        }
        return false;
    };
    
    rep(i, n) {
        if (!pay(a[i])) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}
0