結果

問題 No.1015 おつりは要らないです
ユーザー KoDKoD
提出日時 2020-04-03 22:01:10
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,056 bytes
コンパイル時間 770 ms
コンパイル使用メモリ 84,516 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-09-16 01:34:56
合計ジャッジ時間 3,324 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 2 ms
4,384 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 41 ms
4,380 KB
testcase_11 AC 41 ms
4,376 KB
testcase_12 AC 39 ms
4,376 KB
testcase_13 AC 41 ms
4,380 KB
testcase_14 AC 42 ms
4,380 KB
testcase_15 AC 40 ms
4,380 KB
testcase_16 AC 40 ms
4,380 KB
testcase_17 AC 42 ms
4,376 KB
testcase_18 AC 41 ms
4,380 KB
testcase_19 AC 40 ms
4,380 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 1 ms
4,376 KB
testcase_31 AC 18 ms
4,380 KB
testcase_32 AC 18 ms
4,376 KB
testcase_33 AC 44 ms
4,376 KB
testcase_34 AC 2 ms
4,376 KB
testcase_35 AC 2 ms
4,376 KB
testcase_36 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <numeric>
#include <tuple>

template <class T, class U>
inline bool chmin(T &lhs, const U &rhs) {
  if (lhs > rhs) {
    lhs = rhs;
    return true;
  }
  return false;
}

template <class T, class U>
inline bool chmax(T &lhs, const U &rhs) {
  if (lhs < rhs) {
    lhs = rhs;
    return true;
  }
  return false;
}

// [l, r) from l to r
struct range {
  struct itr {
    int i;
    constexpr itr(int i_): i(i_) { }
    constexpr void operator ++ () { ++i; }
    constexpr int operator * () const { return i; }
    constexpr bool operator != (itr x) const { return i != x.i; }
  };
  const itr l, r;
  constexpr range(int l_, int r_): l(l_), r(std::max(l_, r_)) { }
  constexpr itr begin() const { return l; }
  constexpr itr end() const { return r; }
};

// [l, r) from r to l
struct revrange {
  struct itr {
    int i;
    constexpr itr(int i_): i(i_) { }
    constexpr void operator ++ () { --i; }
    constexpr int operator * () const { return i; }
    constexpr bool operator != (itr x) const { return i != x.i; }
  };
  const itr r, l;
  constexpr revrange(int l_, int r_): l(l_ - 1), r(std::max(l_, r_) - 1) { }
  constexpr itr begin() const { return r; }
  constexpr itr end() const { return l; }
};

int main() {
  int N;
  long long X, Y, Z;
  std::cin >> N >> X >> Y >> Z;
  std::vector<long long> A(N);
  for (long long &x: A) {
    std::cin >> x;
    x = x / 1000 + 1;
  }
  for (long long &x: A) {
    long long t = x / 10;
    if (Z >= t) {
      x -= t * 10;
      Z -= t;
    }
    else {
      x -= Z * 10;
      Z = 0;
    }
    t = x / 5;
    if (Y >= t) {
      x -= t * 5;
      Y -= t;
    }
    else {
      x -= Y * 5;
      Y = 0;
    }
  }
  std::sort(A.rbegin(), A.rend());
  for (long long &x: A) {
    if (Z > 0) {
      --Z;
      x = 0;
    }
    else if (Y > 0) {
      --Y;
      x = 0;
    }
  }
  long long need = std::accumulate(A.cbegin(), A.cend(), 0ll);
  std::cout << (X + Y + Z >= need ? "Yes" : "No") << '\n';
  return 0;
}
0