結果

問題 No.1015 おつりは要らないです
ユーザー kyort0nkyort0n
提出日時 2020-04-03 21:31:43
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 28 ms / 2,000 ms
コード長 1,587 bytes
コンパイル時間 1,869 ms
コンパイル使用メモリ 171,672 KB
実行使用メモリ 4,980 KB
最終ジャッジ日時 2023-08-11 08:37:10
合計ジャッジ時間 4,034 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 1 ms
4,384 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 28 ms
4,908 KB
testcase_11 AC 27 ms
4,892 KB
testcase_12 AC 26 ms
4,732 KB
testcase_13 AC 26 ms
4,908 KB
testcase_14 AC 27 ms
4,980 KB
testcase_15 AC 25 ms
4,736 KB
testcase_16 AC 26 ms
4,760 KB
testcase_17 AC 27 ms
4,800 KB
testcase_18 AC 26 ms
4,744 KB
testcase_19 AC 26 ms
4,764 KB
testcase_20 AC 26 ms
4,456 KB
testcase_21 AC 26 ms
4,380 KB
testcase_22 AC 26 ms
4,424 KB
testcase_23 AC 24 ms
4,404 KB
testcase_24 AC 25 ms
4,504 KB
testcase_25 AC 25 ms
4,476 KB
testcase_26 AC 25 ms
4,376 KB
testcase_27 AC 25 ms
4,376 KB
testcase_28 AC 25 ms
4,424 KB
testcase_29 AC 25 ms
4,424 KB
testcase_30 AC 1 ms
4,376 KB
testcase_31 AC 13 ms
4,796 KB
testcase_32 AC 13 ms
4,816 KB
testcase_33 AC 20 ms
4,964 KB
testcase_34 AC 1 ms
4,380 KB
testcase_35 AC 2 ms
4,380 KB
testcase_36 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

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

const long double EPS = 1e-10;
const long long INF = 1e18;
const long double PI = acos(-1.0L);
//const ll mod = 1000000007;

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, X, Y, Z;
    cin >> N >> X >> Y >> Z;
    vector<ll> A(N);
    for(int i = 0; i < N; i++) {
        cin >> A[i];
        A[i]++;
        ll num = min(Z, A[i] / 10000);
        Z -= num;
        A[i] -= 10000 * num;
    }
    sort(A.begin(), A.end(), greater<ll>());
    for(int i = 0; i < A.size(); i++) {
        if(Z > 0) {
            A[i] -= 10000;
            Z--;
        }
        //cerr << A[i] << endl;
    }
    vector<ll> B;
    for(int i = 0; i < A.size(); i++) {
        if(A[i] <= 0) continue;
        ll num = min(Y, A[i] / 5000);
        B.push_back(A[i] - 5000 * num);
        Y -= num;
    }
    sort(B.begin(), B.end(), greater<ll>());
    N = B.size();
    for(int i = 0; i < B.size(); i++) {
        if(Y > 0) {
            B[i] -= 5000;
            Y--;
        }
        if(B[i] <= 0) continue;
        X -= (B[i] + 999) / 1000;
        //cerr << B[i] << " " << X << endl;
    }
    if(X >= 0) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}
0