結果

問題 No.617 Nafmo、買い出しに行く
ユーザー 💕💖💞💕💖💞
提出日時 2018-02-17 09:41:07
言語 Kotlin
(1.9.23)
結果
WA  
実行時間 -
コード長 521 bytes
コンパイル時間 14,515 ms
コンパイル使用メモリ 441,248 KB
実行使用メモリ 150,832 KB
最終ジャッジ日時 2024-04-30 17:01:36
合計ジャッジ時間 22,707 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 TLE -
testcase_06 TLE -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.kt:1:10: warning: parameter 'args' is never used
fun main(args:Array<String>) {
         ^

ソースコード

diff #

fun main(args:Array<String>) {
  val (n, k) = readLine()!!.split(" ").map{ it.toInt() }
  val a = (1..n).map { 
    readLine()!!.toInt()
  }
  
  val b = Integer.parseInt("1".repeat(a.size), 2)

  println(b)

  val maxs = mutableListOf<Int>()
  (0..b).map { 
    val d = "%${a.size}s".format(Integer.toBinaryString(it)).replace(" ", "0")
    val m = d.toList().map { it.toString() }.zip(a).filter { it.first == "1" }.map { it.second }.sum()
    if( m <= k )
      maxs.add(m)
  }
  println( maxs.sorted()[maxs.size-1] )
}
0