結果

問題 No.1015 おつりは要らないです
ユーザー SSRSSSRS
提出日時 2020-04-03 22:37:09
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 938 bytes
コンパイル時間 1,603 ms
コンパイル使用メモリ 169,456 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-09-16 03:31:16
合計ジャッジ時間 4,113 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

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++){
      a += A[i];
      if (a > X){
        b += (a - X + 4) / 5;
        a -= (a - X + 4) / 5 * 5;
        if (a < 0){
          a = 0;
        }
      }
      if (b > Y){
        c += (b - Y + 1) / 2;
        b -= (b - Y + 1) / 2 * 2;
        if (b < 0){
          b = 0;
        }
      }
      if (c > Z){
        flg = false;
      }
    }
    if (flg){
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  }
}
0