結果

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

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int money[3] = {1000, 5000, 10000};
int num[3];

int main() {
    int N;
    cin >> N;
    for (int i=0; i<3; ++i) cin >> num[i];
    vector<int> A(N);
    for (int i=0; i<N; ++i) {
        cin >> A[i];
        A[i] ++;
    }
    sort(A.rbegin(), A.rend());

    int cnt = N;
    for (int i=0; i<3; ++i) {
        for (int j=0; j<N; ++j) {
            if (num[i] > 0 && A[j] > money[i]) {
                num[i] -= (A[j] / money[i]);
                A[j] -= (A[j] / money[i]) * money[i];
                if (A[j] == 0) cnt --;
                continue;
            }
        }
        if (num[i] == 0) continue;
        sort(A.rbegin(), A.rend());
        for (int j=0; j<N; ++j) {
            if (num[i] > 0 && A[j] > 0) {
                num[i] --;
                A[j] = 0;
                cnt --;
            }
        }
    }
    cout << (cnt == 0 ? "Yes" : "No") << endl;
    return 0;
}
0