結果

問題 No.472 平均順位
ユーザー htkbhtkb
提出日時 2018-06-05 17:55:46
言語 Kotlin
(1.9.23)
結果
AC  
実行時間 851 ms / 2,000 ms
コード長 564 bytes
コンパイル時間 13,313 ms
コンパイル使用メモリ 432,472 KB
実行使用メモリ 75,044 KB
最終ジャッジ日時 2024-04-30 18:42:09
合計ジャッジ時間 25,306 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 376 ms
60,848 KB
testcase_01 AC 382 ms
61,048 KB
testcase_02 AC 380 ms
60,840 KB
testcase_03 AC 377 ms
60,932 KB
testcase_04 AC 408 ms
61,004 KB
testcase_05 AC 381 ms
60,840 KB
testcase_06 AC 393 ms
61,068 KB
testcase_07 AC 419 ms
59,060 KB
testcase_08 AC 530 ms
62,232 KB
testcase_09 AC 550 ms
64,368 KB
testcase_10 AC 560 ms
64,408 KB
testcase_11 AC 633 ms
66,656 KB
testcase_12 AC 609 ms
66,780 KB
testcase_13 AC 741 ms
75,044 KB
testcase_14 AC 851 ms
73,704 KB
testcase_15 AC 731 ms
75,044 KB
testcase_16 AC 825 ms
74,872 KB
testcase_17 AC 810 ms
74,832 KB
testcase_18 AC 590 ms
64,704 KB
testcase_19 AC 686 ms
72,708 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
    val dp = LongArray(P+4)
    dp.fill(inf)
    dp[3] = 0
    for (i in 0 until N) {
        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)
        }
    }
    println(dp[P+3].toDouble() / N.toDouble())
}
0