結果

問題 No.156 キャンディー・ボックス
ユーザー noriocnorioc
提出日時 2015-09-25 02:42:24
言語 Scala(Beta)
(3.4.0)
結果
AC  
実行時間 1,020 ms / 2,000 ms
コード長 390 bytes
コンパイル時間 11,986 ms
コンパイル使用メモリ 260,456 KB
実行使用メモリ 63,560 KB
最終ジャッジ日時 2023-08-12 18:36:31
合計ジャッジ時間 48,214 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 993 ms
63,488 KB
testcase_01 AC 992 ms
63,276 KB
testcase_02 AC 978 ms
63,168 KB
testcase_03 AC 978 ms
63,008 KB
testcase_04 AC 992 ms
63,080 KB
testcase_05 AC 993 ms
62,992 KB
testcase_06 AC 1,000 ms
63,020 KB
testcase_07 AC 991 ms
63,112 KB
testcase_08 AC 993 ms
63,160 KB
testcase_09 AC 1,001 ms
63,000 KB
testcase_10 AC 993 ms
63,248 KB
testcase_11 AC 989 ms
63,120 KB
testcase_12 AC 1,000 ms
63,120 KB
testcase_13 AC 1,001 ms
62,988 KB
testcase_14 AC 995 ms
63,092 KB
testcase_15 AC 1,000 ms
63,064 KB
testcase_16 AC 997 ms
63,020 KB
testcase_17 AC 974 ms
63,356 KB
testcase_18 AC 973 ms
63,560 KB
testcase_19 AC 978 ms
63,056 KB
testcase_20 AC 991 ms
63,036 KB
testcase_21 AC 996 ms
63,060 KB
testcase_22 AC 991 ms
62,972 KB
testcase_23 AC 984 ms
63,020 KB
testcase_24 AC 976 ms
62,964 KB
testcase_25 AC 982 ms
62,780 KB
testcase_26 AC 1,020 ms
63,156 KB
testcase_27 AC 982 ms
63,172 KB
testcase_28 AC 974 ms
63,368 KB
testcase_29 AC 974 ms
63,388 KB
testcase_30 AC 979 ms
63,020 KB
testcase_31 AC 989 ms
63,068 KB
testcase_32 AC 992 ms
63,404 KB
testcase_33 AC 989 ms
63,364 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import scala.math._

object Main {
  def main(args: Array[String]) = {
    val sc = new java.util.Scanner(System.in)
    val n, m = sc.nextInt
    val xs = (1 to n).map { _ => sc.nextInt }.toList.sorted

    def rec(m: Int, xs: List[Int]): Int = xs match {
      case Nil => 0
      case (y :: ys) =>
        if (m < y) 0
        else 1 + rec(m - y, ys)
    }
    println(rec(m, xs))
  }
}
0