結果

問題 No.1015 おつりは要らないです
ユーザー yudedakoyudedako
提出日時 2022-01-26 18:25:45
言語 Scala(Beta)
(3.4.0)
結果
WA  
実行時間 -
コード長 642 bytes
コンパイル時間 14,412 ms
コンパイル使用メモリ 263,528 KB
実行使用メモリ 79,972 KB
最終ジャッジ日時 2023-08-25 00:18:16
合計ジャッジ時間 72,080 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 944 ms
62,460 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 AC 958 ms
62,648 KB
testcase_04 AC 947 ms
62,572 KB
testcase_05 AC 940 ms
62,744 KB
testcase_06 AC 939 ms
62,336 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 952 ms
62,536 KB
testcase_10 AC 1,889 ms
79,520 KB
testcase_11 AC 1,816 ms
79,552 KB
testcase_12 AC 1,859 ms
78,988 KB
testcase_13 AC 1,823 ms
79,972 KB
testcase_14 AC 1,855 ms
79,824 KB
testcase_15 AC 1,808 ms
78,636 KB
testcase_16 AC 1,795 ms
79,152 KB
testcase_17 AC 1,814 ms
79,592 KB
testcase_18 AC 1,783 ms
78,580 KB
testcase_19 AC 1,794 ms
78,576 KB
testcase_20 AC 1,898 ms
77,804 KB
testcase_21 AC 1,923 ms
77,048 KB
testcase_22 AC 1,892 ms
77,044 KB
testcase_23 AC 1,890 ms
77,452 KB
testcase_24 AC 1,950 ms
77,576 KB
testcase_25 AC 1,925 ms
77,016 KB
testcase_26 AC 1,839 ms
77,112 KB
testcase_27 AC 1,859 ms
77,540 KB
testcase_28 AC 1,948 ms
78,516 KB
testcase_29 AC 1,907 ms
77,624 KB
testcase_30 AC 949 ms
62,652 KB
testcase_31 AC 1,346 ms
73,284 KB
testcase_32 WA -
testcase_33 AC 1,306 ms
73,708 KB
testcase_34 AC 950 ms
62,472 KB
testcase_35 AC 954 ms
62,992 KB
testcase_36 AC 953 ms
62,504 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import scala.annotation.tailrec
import scala.io.StdIn.*
import scala.math.*

@main def main =
  val Array(n, x, y, z) = readLine().split(' ').map(_.toInt)
  val pay = readLine().split(' ').map(_.toInt)
  val bill = Array(1000 -> x, 5000 -> y, 10000 -> z)
  for (money, count) <- bill.reverseIterator do
    var rest = count
    for i <- 0 until n do
      val use = min(rest, pay(i) / money)
      pay(i) -= use * money
      rest -= use
    for i <- (0 until n).sortBy(i => pay(i) % money).reverseIterator do
      if rest > 0 && pay(i) >= 0 then
        rest -= 1
        pay(i) -= money
  println(if pay.forall(_ < 0) then "Yes" else "No")
0