結果

問題 No.1015 おつりは要らないです
ユーザー yudedakoyudedako
提出日時 2022-01-26 18:26:36
言語 Scala(Beta)
(3.4.0)
結果
AC  
実行時間 1,750 ms / 2,000 ms
コード長 686 bytes
コンパイル時間 9,595 ms
コンパイル使用メモリ 261,344 KB
実行使用メモリ 74,024 KB
最終ジャッジ日時 2023-08-25 00:19:56
合計ジャッジ時間 63,866 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 950 ms
62,540 KB
testcase_01 AC 961 ms
62,540 KB
testcase_02 AC 953 ms
62,676 KB
testcase_03 AC 955 ms
62,700 KB
testcase_04 AC 947 ms
62,332 KB
testcase_05 AC 955 ms
62,624 KB
testcase_06 AC 956 ms
62,644 KB
testcase_07 AC 965 ms
62,704 KB
testcase_08 AC 953 ms
62,692 KB
testcase_09 AC 966 ms
62,720 KB
testcase_10 AC 1,750 ms
72,412 KB
testcase_11 AC 1,740 ms
72,012 KB
testcase_12 AC 1,716 ms
72,152 KB
testcase_13 AC 1,727 ms
72,276 KB
testcase_14 AC 1,716 ms
73,732 KB
testcase_15 AC 1,735 ms
72,096 KB
testcase_16 AC 1,703 ms
71,312 KB
testcase_17 AC 1,703 ms
71,848 KB
testcase_18 AC 1,696 ms
71,320 KB
testcase_19 AC 1,700 ms
71,532 KB
testcase_20 AC 1,685 ms
71,524 KB
testcase_21 AC 1,679 ms
69,504 KB
testcase_22 AC 1,673 ms
69,964 KB
testcase_23 AC 1,650 ms
69,180 KB
testcase_24 AC 1,677 ms
70,440 KB
testcase_25 AC 1,707 ms
70,556 KB
testcase_26 AC 1,681 ms
71,360 KB
testcase_27 AC 1,700 ms
70,252 KB
testcase_28 AC 1,683 ms
70,584 KB
testcase_29 AC 1,662 ms
70,400 KB
testcase_30 AC 949 ms
62,376 KB
testcase_31 AC 1,287 ms
73,388 KB
testcase_32 AC 1,274 ms
74,024 KB
testcase_33 AC 1,275 ms
73,772 KB
testcase_34 AC 946 ms
62,240 KB
testcase_35 AC 951 ms
62,516 KB
testcase_36 AC 963 ms
62,620 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
      if pay(i) >= money then
        val use = min(rest, pay(i) / money)
        pay(i) -= use * money
        rest -= use
    for i <- (0 until n).sortWith((i, j) => pay(i) % money > pay(j) % money) do
      if rest > 0 && pay(i) >= 0 then
        rest -= 1
        pay(i) -= money
  println(if pay.forall(_ < 0) then "Yes" else "No")
0