結果

問題 No.156 キャンディー・ボックス
ユーザー noriocnorioc
提出日時 2015-09-25 02:42:24
言語 Scala(Beta)
(3.4.0)
結果
AC  
実行時間 1,008 ms / 2,000 ms
コード長 390 bytes
コンパイル時間 11,674 ms
コンパイル使用メモリ 258,828 KB
実行使用メモリ 65,876 KB
最終ジャッジ日時 2024-04-30 13:42:06
合計ジャッジ時間 47,835 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,002 ms
65,552 KB
testcase_01 AC 992 ms
65,652 KB
testcase_02 AC 986 ms
65,520 KB
testcase_03 AC 1,008 ms
65,704 KB
testcase_04 AC 1,005 ms
65,644 KB
testcase_05 AC 989 ms
65,612 KB
testcase_06 AC 1,005 ms
65,492 KB
testcase_07 AC 1,008 ms
65,472 KB
testcase_08 AC 995 ms
65,872 KB
testcase_09 AC 1,004 ms
65,704 KB
testcase_10 AC 996 ms
65,828 KB
testcase_11 AC 1,000 ms
65,728 KB
testcase_12 AC 997 ms
65,628 KB
testcase_13 AC 985 ms
65,712 KB
testcase_14 AC 1,008 ms
65,724 KB
testcase_15 AC 1,002 ms
65,756 KB
testcase_16 AC 990 ms
65,612 KB
testcase_17 AC 989 ms
65,372 KB
testcase_18 AC 995 ms
65,608 KB
testcase_19 AC 993 ms
65,876 KB
testcase_20 AC 1,001 ms
65,468 KB
testcase_21 AC 1,006 ms
65,604 KB
testcase_22 AC 997 ms
65,720 KB
testcase_23 AC 979 ms
65,620 KB
testcase_24 AC 997 ms
65,436 KB
testcase_25 AC 997 ms
65,356 KB
testcase_26 AC 996 ms
65,640 KB
testcase_27 AC 987 ms
65,636 KB
testcase_28 AC 995 ms
65,684 KB
testcase_29 AC 1,002 ms
65,800 KB
testcase_30 AC 1,005 ms
65,732 KB
testcase_31 AC 990 ms
65,780 KB
testcase_32 AC 998 ms
65,784 KB
testcase_33 AC 1,000 ms
65,444 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