結果

問題 No.1015 おつりは要らないです
ユーザー le_panda_noir
提出日時 2020-06-14 17:55:12
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 1,249 bytes
コンパイル時間 1,047 ms
コンパイル使用メモリ 96,688 KB
最終ジャッジ日時 2025-01-11 04:16:35
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 15 WA * 18
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
using namespace std;
void ins() {}
template<class T,class... Rest>void ins(T& v,Rest&... rest){cin>>v;ins(rest...);}
#define rep(i,n) for(int i=0,_i=(n);i<_i;++i)
#define all(f,c,...) (([&](decltype((c)) cccc) { return (f)(begin(cccc), end(cccc), ## __VA_ARGS__); })(c))

int main() {
  int N, X, Y, Z;
  ins(N, X, Y, Z);

  priority_queue<int> q;
  rep(i, N) {
    int A; cin >> A;
    q.push(A);
  }
  while (!q.empty() && Z > 0) {
    int p = q.top(); q.pop();
    if (p >= 10000) {
      if (Z * 10000 > p) {
        Z -= p / 10000;
        p -= p / 10000 * 10000;
        continue;
      }
      p -= Z * 10000;
      Z = 0;
      q.push(p);
      continue;
    }
    --Z;
  }
  while (!q.empty() && Y > 0) {
    int p = q.top(); q.pop();
    if (p >= 5000) {
      if (Y * 5000 > p) {
        Y -= p / 5000;
        p -= p / 5000 * 5000;
        continue;
      }
      p -= Y * 5000;
      Y = 0;
      q.push(p);
      continue;
    }
    --Y;
  }
  while (!q.empty() && X > 0) {
    int p = q.top(); q.pop();
    X -= ceil((p + (p % 1000)) / 1000.0);
  }
  if (!q.empty()) {
    cout << "No\n";
    return 0;
  }
  cout << "Yes\n";

  return 0;
}
0