結果

問題 No.1015 おつりは要らないです
ユーザー homesentinelhomesentinel
提出日時 2020-04-03 21:46:48
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 3,077 bytes
コンパイル時間 1,198 ms
コンパイル使用メモリ 120,688 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-16 00:54:58
合計ジャッジ時間 3,511 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>
#include <cstring>
#include <cassert>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

typedef long long int ll;
using ll = long long int;
using ull = long long unsigned int;
using Int = long long int;
using uInt = long long unsigned int;
using Double = long double;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//edit
class Solve {
public:
    void solve() {
        Int N, X, Y, Z;
        cin >> N >> X >> Y >> Z;
        vector<Int> A(N);
        for (int i = 0; i < N; ++i) {
            cin >> A[i];
        }

        auto kiri = [&A](Int base) {
            for (int i = 0; i < A.size(); ++i) {
                if (base == 1000 && A[i] % base == 0) {
                    A[i] += 1000;
                } else {
                    A[i] = (A[i] + base - 1) / base * base;
                }
            }
        };

        kiri(1000);
        auto cmp = [](Int l, Int r, Int base) {
            l %= base;
            r %= base;
            return l < r;
        };
        sort(all(A), [cmp](Int l, Int r) {
//            l %= 1000;
//            r %= 1000;
//            return l < r;
            return cmp(l, r, 5000);
        });
        for (int i = 0; i < A.size(); ++i) {
            Int dec = min((A[i] % 5000) / 1000, X);
            X -= dec;
            A[i] -= dec * 1000;
        }
        Y += X / 5;
        X = 0;


        kiri(5000);
        sort(all(A), [cmp](Int l, Int r) {
//            l %= 5000;
//            r %= 5000;
//            return l < r;
            return cmp(l, r, 10000);
        });
        for (int i = 0; i < A.size(); ++i) {
            Int dec = min((A[i] % 10000) / 5000, Y);
            Y -= dec;
            A[i] -= dec * 5000;
        }
        Z += Y / 2;
        Y = 0;


        kiri(10000);
        for (int i = 0; i < A.size(); ++i) {
            Int dec = A[i] / 10000;
            Z -= dec;
        }

        if (Z >= 0) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }


    }
};


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    Solve().solve();


    return 0;
}
0