結果

問題 No.1015 おつりは要らないです
ユーザー imoni_kawaiiimoni_kawaii
提出日時 2020-06-12 09:54:35
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,731 bytes
コンパイル時間 2,295 ms
コンパイル使用メモリ 209,276 KB
実行使用メモリ 6,380 KB
最終ジャッジ日時 2023-09-06 08:57:24
合計ジャッジ時間 6,236 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,384 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 37 ms
5,868 KB
testcase_11 AC 38 ms
6,260 KB
testcase_12 AC 35 ms
5,964 KB
testcase_13 AC 37 ms
5,960 KB
testcase_14 AC 38 ms
6,176 KB
testcase_15 AC 36 ms
5,868 KB
testcase_16 AC 37 ms
5,864 KB
testcase_17 AC 37 ms
6,120 KB
testcase_18 AC 36 ms
6,116 KB
testcase_19 AC 37 ms
5,868 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,380 KB
testcase_31 AC 18 ms
6,260 KB
testcase_32 AC 17 ms
6,148 KB
testcase_33 AC 24 ms
6,128 KB
testcase_34 AC 2 ms
4,376 KB
testcase_35 WA -
testcase_36 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define REP(i, m, n) for(int i = (int)(m); i < (int)(n); ++i)
#define rep(i, n) REP(i, 0, n)
using namespace std;
using ll = long long;
using ld = long double;
template<class T, class U> inline bool chmax(T &a, const U &b) { if(a < b) { a = b; return true; } return false; }
template<class T, class U> inline bool chmin(T &a, const U &b) { if(a > b) { a = b; return true; } return false; }

ll n, x[3], a[100000];
ll mul[3] = { -1,5,2 };
using pll = pair<ll, ll>;

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  cin >> n;
  rep(i, 3) cin >> x[i];
  rep(i, n) cin >> a[i];
  vector<pll> b(n);
  ll sum = 0;
  rep(i, n) {
    if(a[i]%1000 == 0) a[i]++;
    ll c = (a[i]+999)/1000;
    b[i] = {c%mul[1], c/mul[1]};
    sum += c;
  }
  sort(b.rbegin(), b.rend());
  vector<ll> na(n, 0);
  rep(i, n) {
    if(sum <= x[0]) break;
    if(sum-b[i].second*mul[1] >= x[0]) {
      sum -= b[i].second*mul[1];
      na[i] += b[i].second;
    }
    else {
      ll t = (sum-x[0]+mul[1]-1)/mul[1];
      sum -= t*mul[1];
      na[i] += t;
    }
  }
  rep(i, n) {
    if(sum <= x[0]) break;
    sum -= b[i].first;
    na[i]++;
  }

  sum = 0;
  rep(i, n) {
    b[i] = {na[i]%mul[2], na[i]/mul[2]};
    sum += na[i];
  }
  sort(b.rbegin(), b.rend());
  na.assign(n, 0);
  rep(i, n) {
    if(sum <= x[1]) break;
    if(sum-b[i].second*mul[2] >= x[1]) {
      sum -= b[i].second*mul[2];
      na[i] += b[i].second;
    }
    else {
      ll t = (sum-x[1]+mul[2]-1)/mul[2];
      sum -= t*mul[2];
      na[i] += t;
    }
  }
  rep(i, n) {
    if(sum <= x[1]) break;
    sum -= b[i].first;
    na[i]++;
  }

  sum = 0;
  rep(i, n) {
    sum += na[i];
  }
  cout << (sum > x[2] ? "No" : "Yes") << '\n';
  return 0;
}
0