結果

問題 No.1015 おつりは要らないです
ユーザー 0w10w1
提出日時 2020-11-17 01:54:53
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 1,046 bytes
コンパイル時間 2,047 ms
コンパイル使用メモリ 204,996 KB
実行使用メモリ 8,500 KB
最終ジャッジ日時 2023-09-30 07:38:17
合計ジャッジ時間 6,856 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 RE -
testcase_04 RE -
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 AC 82 ms
7,980 KB
testcase_21 AC 79 ms
8,000 KB
testcase_22 AC 79 ms
7,840 KB
testcase_23 AC 75 ms
7,712 KB
testcase_24 AC 82 ms
8,060 KB
testcase_25 AC 78 ms
7,900 KB
testcase_26 AC 77 ms
7,824 KB
testcase_27 AC 77 ms
7,928 KB
testcase_28 AC 74 ms
7,764 KB
testcase_29 AC 77 ms
7,976 KB
testcase_30 AC 1 ms
4,376 KB
testcase_31 AC 21 ms
8,084 KB
testcase_32 AC 21 ms
8,040 KB
testcase_33 RE -
testcase_34 AC 2 ms
4,380 KB
testcase_35 AC 2 ms
4,380 KB
testcase_36 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main() {
  ios::sync_with_stdio(false);

  int N, X, Y, Z; {
    cin >> N >> X >> Y >> Z;
  }

  vector<int> A(N); {
    for (int i = 0; i < N; ++i) cin >> A[i];
  }

  multiset<int> bag(A.begin(), A.end()); {
    while (bag.size()) {
      int v = *--bag.end();
      bag.erase(--bag.end());

      int dz = min(Z, v / 10000); {
        Z -= dz;
        v -= dz * 10000;
      }
      assert(v < 10000);
      if (dz) { bag.insert(v); continue; }

      if (Z) { --Z; continue; }

      int dy = min(Y, v / 5000); {
        Y -= dy;
        v -= dy * 5000;
      }
      assert(v < 5000);
      if (dy) { bag.insert(v); continue; }

      if (Y) { --Y; continue; }

      int64_t tot = (int64_t) X * 1000 + (int64_t) Y * 5000 + (int64_t) Z * 10000;
      if (tot <= v) { bag.insert(v); break; }

      int dx = min(X, (v + 1000) / 1000); {
        X -= dx;
        v -= dx * 1000;
      }
      assert(X >= 0);
      assert(v < 0);
    }
  }

  cout << (bag.empty() ? "Yes" : "No") << endl;
}

0