結果

問題 No.1015 おつりは要らないです
ユーザー SSRS
提出日時 2020-04-03 23:00:51
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 1,037 bytes
コンパイル時間 1,522 ms
コンパイル使用メモリ 173,136 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-07-03 05:34:49
合計ジャッジ時間 4,054 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample WA * 4
other AC * 7 WA * 26
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
int main(){
  int N, X, Y, Z;
  cin >> N >> X >> Y >> Z;
  vector<int> A(N);
  sort(A.begin(), A.end());
  reverse(A.begin(), A.end());
  for (int i = 0; i < N; i++){
    cin >> A[i];
    A[i] = (A[i] + 1000) / 1000;
  }
  long long total = 0;
  for (int i = 0; i < N; i++){
    total += A[i];
  }
  if (total > X + Y * 5 + Z * 10){
    cout << "No" << endl;
  } else {
    bool flg = true;
    int a = 0, b = 0, c = 0;
    for (int i = 0; i < N; i++){
      int pa = a, pb = b;
      a += A[i];
      if (a > X){
        b += (a - X + 4) / 5;
        a -= (a - X + 4) / 5 * 5;
        if (a < pa){
          a = pa;
        }
      }
      if (b > Y){
        c += (b - Y + 1) / 2;
        b -= (b - Y + 1) / 2 * 2;
        if (b < pb){
          b = pb;
        }
      }
      if (c > Z){
        flg = false;
      }
      cout << "a = " << a << ", b = " << b << ", c = " << c << endl;
    }
    if (flg){
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  }
}
0