結果

問題 No.472 平均順位
ユーザー htkbhtkb
提出日時 2018-06-05 11:43:58
言語 Kotlin
(1.9.23)
結果
AC  
実行時間 1,051 ms / 2,000 ms
コード長 634 bytes
コンパイル時間 10,390 ms
コンパイル使用メモリ 435,752 KB
実行使用メモリ 94,456 KB
最終ジャッジ日時 2024-04-30 18:41:00
合計ジャッジ時間 22,079 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 291 ms
55,332 KB
testcase_01 AC 301 ms
55,332 KB
testcase_02 AC 296 ms
55,236 KB
testcase_03 AC 295 ms
55,280 KB
testcase_04 AC 328 ms
57,664 KB
testcase_05 AC 295 ms
55,560 KB
testcase_06 AC 307 ms
57,564 KB
testcase_07 AC 328 ms
57,572 KB
testcase_08 AC 438 ms
67,036 KB
testcase_09 AC 462 ms
87,696 KB
testcase_10 AC 499 ms
87,564 KB
testcase_11 AC 552 ms
87,904 KB
testcase_12 AC 528 ms
88,004 KB
testcase_13 AC 736 ms
90,076 KB
testcase_14 AC 997 ms
93,036 KB
testcase_15 AC 737 ms
90,548 KB
testcase_16 AC 1,051 ms
94,456 KB
testcase_17 AC 1,024 ms
94,316 KB
testcase_18 AC 474 ms
87,776 KB
testcase_19 AC 649 ms
87,956 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.kt:3:10: warning: parameter 'args' is never used
fun main(args: Array<String>) {
         ^

ソースコード

diff #

import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val (N, P) = Pair(sc.nextInt(), sc.nextInt())
    val q = Array(N, { arrayOf(sc.nextInt(), sc.nextInt(), sc.nextInt() )})
    val inf = 100000L*N
    var dp = Array(P+4, { inf })
    dp[3] = 0
    val dp2 = Array(P+4, { inf })
    for (i in 0 until N) {
        val _dp = dp2.clone()
        for (dest in Math.min(3*i+6, P+3) downTo 3) {
            _dp[dest] = Math.min(Math.min(Math.min(dp[dest]+q[i][0], dp[dest-1]+q[i][1]), dp[dest-2]+q[i][2]), dp[dest-3]+1)
        }
        dp = _dp
    }
    println(dp[P+3].toDouble() / N.toDouble())
}
0