結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,384 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 2 ms
4,384 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 76 ms
7,864 KB
testcase_11 AC 76 ms
7,984 KB
testcase_12 AC 71 ms
7,848 KB
testcase_13 AC 74 ms
7,864 KB
testcase_14 AC 78 ms
8,112 KB
testcase_15 AC 70 ms
7,904 KB
testcase_16 AC 73 ms
7,860 KB
testcase_17 AC 78 ms
7,988 KB
testcase_18 AC 73 ms
7,956 KB
testcase_19 AC 71 ms
7,932 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,376 KB
testcase_31 AC 21 ms
8,048 KB
testcase_32 AC 21 ms
8,296 KB
testcase_33 AC 29 ms
8,120 KB
testcase_34 AC 1 ms
4,380 KB
testcase_35 AC 2 ms
4,376 KB
testcase_36 AC 2 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;
      }
      if (v < 0) continue;
      if (dz) { bag.insert(v); continue; }
      int dy = min(Y, v / 5000); {
        Y -= dy;
        v -= dy * 5000;
      }
      if (v < 0) continue;
      if (dy) { bag.insert(v); continue; }

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

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

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

0