結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 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 2 ms
4,376 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 72 ms
7,864 KB
testcase_11 AC 77 ms
8,076 KB
testcase_12 AC 70 ms
7,800 KB
testcase_13 AC 76 ms
7,832 KB
testcase_14 AC 83 ms
8,040 KB
testcase_15 AC 71 ms
7,868 KB
testcase_16 AC 74 ms
7,824 KB
testcase_17 AC 74 ms
8,080 KB
testcase_18 AC 72 ms
7,804 KB
testcase_19 AC 74 ms
7,860 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,084 KB
testcase_32 AC 20 ms
8,176 KB
testcase_33 AC 29 ms
8,048 KB
testcase_34 AC 2 ms
4,376 KB
testcase_35 AC 2 ms
4,376 KB
testcase_36 AC 2 ms
4,376 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; }

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

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

0