結果

問題 No.1457 ツブ消ししとるなHard
ユーザー fukafukatanifukafukatani
提出日時 2021-06-23 22:08:53
言語 Scala(Beta)
(3.4.0)
結果
WA  
実行時間 -
コード長 828 bytes
コンパイル時間 9,623 ms
コンパイル使用メモリ 270,496 KB
実行使用メモリ 65,456 KB
最終ジャッジ日時 2023-09-07 03:55:31
合計ジャッジ時間 34,437 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,049 ms
64,372 KB
testcase_01 AC 1,001 ms
63,072 KB
testcase_02 AC 1,046 ms
64,252 KB
testcase_03 AC 1,051 ms
63,748 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 1,011 ms
63,164 KB
testcase_08 AC 1,012 ms
62,988 KB
testcase_09 AC 1,099 ms
64,100 KB
testcase_10 AC 1,087 ms
64,280 KB
testcase_11 AC 1,088 ms
64,296 KB
testcase_12 AC 1,118 ms
64,116 KB
testcase_13 AC 1,095 ms
64,452 KB
testcase_14 AC 1,069 ms
64,188 KB
testcase_15 AC 1,096 ms
64,292 KB
testcase_16 AC 1,089 ms
64,148 KB
testcase_17 AC 1,005 ms
63,312 KB
testcase_18 AC 1,040 ms
64,112 KB
testcase_19 WA -
testcase_20 AC 1,037 ms
64,028 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) {
        0l
      } else {
        dp(i)(z * (i + init_use) - init).toLong
      }
    ).sum
    println(ans)
  }
}
0