結果

問題 No.1015 おつりは要らないです
ユーザー 0w10w1
提出日時 2020-11-17 01:57:24
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 68 ms / 2,000 ms
コード長 1,168 bytes
コンパイル時間 1,774 ms
コンパイル使用メモリ 209,464 KB
実行使用メモリ 8,320 KB
最終ジャッジ日時 2024-04-29 06:20:56
合計ジャッジ時間 4,278 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 1 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 59 ms
7,936 KB
testcase_11 AC 61 ms
8,140 KB
testcase_12 AC 56 ms
7,936 KB
testcase_13 AC 58 ms
8,064 KB
testcase_14 AC 60 ms
8,192 KB
testcase_15 AC 56 ms
7,936 KB
testcase_16 AC 59 ms
7,936 KB
testcase_17 AC 60 ms
8,064 KB
testcase_18 AC 57 ms
7,936 KB
testcase_19 AC 60 ms
7,936 KB
testcase_20 AC 65 ms
8,192 KB
testcase_21 AC 63 ms
7,936 KB
testcase_22 AC 64 ms
7,936 KB
testcase_23 AC 59 ms
7,936 KB
testcase_24 AC 66 ms
8,192 KB
testcase_25 AC 68 ms
7,936 KB
testcase_26 AC 66 ms
7,984 KB
testcase_27 AC 67 ms
7,936 KB
testcase_28 AC 66 ms
8,064 KB
testcase_29 AC 65 ms
7,936 KB
testcase_30 AC 1 ms
5,376 KB
testcase_31 AC 17 ms
8,192 KB
testcase_32 AC 19 ms
8,192 KB
testcase_33 AC 27 ms
8,320 KB
testcase_34 AC 2 ms
5,376 KB
testcase_35 AC 1 ms
5,376 KB
testcase_36 AC 2 ms
5,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 (dz) { bag.insert(v); continue; }

      dz = min(Z, (v + 10000) / 10000); {
        Z -= dz;
        v -= dz * 10000;
      }
      if (v < 0) continue;

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

      dy = min(Y, (v + 5000) / 5000); {
        Y -= dy;
        v -= dy * 5000;
      }
      if (v < 0) 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