結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 70 ms
7,960 KB
testcase_11 AC 73 ms
7,980 KB
testcase_12 AC 68 ms
7,728 KB
testcase_13 AC 70 ms
7,916 KB
testcase_14 AC 77 ms
8,108 KB
testcase_15 AC 71 ms
7,716 KB
testcase_16 AC 73 ms
7,924 KB
testcase_17 AC 77 ms
8,040 KB
testcase_18 AC 70 ms
7,960 KB
testcase_19 AC 68 ms
7,784 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 WA -
testcase_32 AC 20 ms
8,060 KB
testcase_33 AC 28 ms
8,132 KB
testcase_34 WA -
testcase_35 WA -
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;
      }
      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; if (X) --X; else if (Y) --Y; else if (Z) --Z; else { bag.insert(v); break; } continue; }
      if (Y) { --Y; if (X) --X; else if (Y) --Y; { bag.insert(v); break; } continue; }
      int dx = min(X, (v + 1000) / 1000); {
        X -= dx;
        v -= dx * 1000;
      }
      assert(v < 0);
    }
  }

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

0