結果

問題 No.1457 ツブ消ししとるなHard
ユーザー fukafukatanifukafukatani
提出日時 2021-06-23 22:07:12
言語 Scala(Beta)
(3.4.0)
結果
WA  
実行時間 -
コード長 820 bytes
コンパイル時間 15,259 ms
コンパイル使用メモリ 265,376 KB
実行使用メモリ 64,660 KB
最終ジャッジ日時 2023-09-07 03:52:52
合計ジャッジ時間 41,007 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,037 ms
64,136 KB
testcase_01 AC 986 ms
63,048 KB
testcase_02 AC 1,034 ms
64,268 KB
testcase_03 AC 1,022 ms
63,668 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 1,000 ms
63,316 KB
testcase_08 AC 1,002 ms
63,576 KB
testcase_09 AC 1,084 ms
64,288 KB
testcase_10 AC 1,085 ms
64,528 KB
testcase_11 AC 1,056 ms
64,092 KB
testcase_12 AC 1,105 ms
64,112 KB
testcase_13 AC 1,085 ms
64,128 KB
testcase_14 AC 1,048 ms
64,320 KB
testcase_15 AC 1,074 ms
64,516 KB
testcase_16 AC 1,088 ms
64,392 KB
testcase_17 AC 998 ms
63,276 KB
testcase_18 AC 1,038 ms
64,188 KB
testcase_19 WA -
testcase_20 AC 1,032 ms
64,060 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner

object Main extends App {
  val sc = new Scanner(System.in)
  val n, m, x, y, z = sc.nextInt
  val a = List.fill(n)(sc.nextInt).filter(_ > y)

  val init = a.filter(_ >= x).sum
  val init_use = a.count(_ >= x)

  if (init_use > m) {
    println("Handicapped")
  } else {
    val b = a.filter(_ < x)
    val dp = Array.fill(b.size + 1, n * 50 + 1)(0)
    dp(0)(0) = 1
    for (bnum <- b; prev_used <- b.indices.reverse; prev_sum <- 0 to m * 50 - bnum) {
      dp(prev_used + 1)(prev_sum + bnum) += dp(prev_used )(prev_sum)
    }
    // dp.foreach(s => Console.err.println(s.mkString(" ")))
    val ans = (1 to m - init_use).map(i =>
      if (z * (i + init_use) < init || i >= dp.size) {
        0
      } else {
        dp(i)(z * (i + init_use) - init)
      }
    ).sum
    println(ans)
  }
}
0