結果

問題 No.1015 おつりは要らないです
ユーザー yudedakoyudedako
提出日時 2022-01-26 18:29:13
言語 Scala(Beta)
(3.4.0)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 673 bytes
コンパイル時間 9,866 ms
コンパイル使用メモリ 258,956 KB
実行使用メモリ 79,700 KB
最終ジャッジ日時 2023-08-25 00:24:55
合計ジャッジ時間 67,524 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 953 ms
63,036 KB
testcase_01 AC 945 ms
63,056 KB
testcase_02 AC 957 ms
62,652 KB
testcase_03 AC 956 ms
62,572 KB
testcase_04 AC 962 ms
62,780 KB
testcase_05 AC 959 ms
62,728 KB
testcase_06 AC 955 ms
62,636 KB
testcase_07 AC 954 ms
62,748 KB
testcase_08 AC 961 ms
62,660 KB
testcase_09 AC 971 ms
63,096 KB
testcase_10 AC 1,900 ms
79,700 KB
testcase_11 AC 1,823 ms
79,460 KB
testcase_12 AC 1,858 ms
78,332 KB
testcase_13 AC 1,863 ms
79,224 KB
testcase_14 AC 1,882 ms
79,524 KB
testcase_15 AC 1,831 ms
78,980 KB
testcase_16 AC 1,811 ms
79,180 KB
testcase_17 AC 1,848 ms
79,580 KB
testcase_18 AC 1,806 ms
78,652 KB
testcase_19 AC 1,827 ms
79,052 KB
testcase_20 AC 1,969 ms
78,236 KB
testcase_21 AC 1,867 ms
77,784 KB
testcase_22 AC 1,866 ms
77,276 KB
testcase_23 AC 1,895 ms
77,656 KB
testcase_24 AC 1,970 ms
76,880 KB
testcase_25 TLE -
testcase_26 AC 1,947 ms
76,924 KB
testcase_27 AC 1,913 ms
77,356 KB
testcase_28 AC 1,933 ms
77,364 KB
testcase_29 AC 1,926 ms
78,184 KB
testcase_30 AC 959 ms
62,636 KB
testcase_31 AC 1,460 ms
72,656 KB
testcase_32 AC 1,356 ms
72,456 KB
testcase_33 AC 1,338 ms
73,836 KB
testcase_34 AC 956 ms
62,672 KB
testcase_35 AC 956 ms
62,740 KB
testcase_36 AC 950 ms
62,264 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) > 0 then
        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