結果

問題 No.1015 おつりは要らないです
ユーザー le_panda_noirle_panda_noir
提出日時 2020-06-14 17:38:23
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,402 bytes
コンパイル時間 964 ms
コンパイル使用メモリ 90,008 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-09 22:04:08
合計ジャッジ時間 5,332 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
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);

  vector<int> A(N);
  rep(i, N) {
    cin >> A[i];
    A[i] += A[i] % 1000 == 0;
    A[i] = ceil(A[i] / 1000.0) * 1000;
  }
  all(sort, A);
  rep(i, N) {
    // なるべくギリギリで払いたい
    if (Z * 10000 >= A[i]) {
      Z -= A[i] / 10000;
      A[i] -= (A[i] / 10000) * 10000;
      if (X * 1000 + Y * 5000 < A[i]) {
        // 1万を追加で使う
        --Z;
        continue;
      }
      Y -= A[i] / 5000;
      A[i] -= (A[i] / 5000) * 5000;
      if (X * 1000 < A[i]) {
        --Y;
        continue;
      }
      X -= ceil(A[i] / 1000.0);
      continue;
    }
    A[i] -= Z * 10000;
    Z = 0;
    if (Y * 5000 < A[i]) {
      A[i] -= Y * 5000;
      Y = 0;
      if (X * 1000 < A[i]) {
        cout << "No\n";
        return 0;
      }
      X -= ceil(A[i] / 1000.0);
      continue;
    }
    Y -= A[i] / 5000;
    A[i] -= (A[i] / 5000) * 5000;
    if (X * 1000 < A[i]) {
      --Y;
      continue;
    }
    X -= ceil(A[i] / 1000.0);
  }
  cout << "Yes\n";

  return 0;
}
0