結果

問題 No.472 平均順位
ユーザー htkbhtkb
提出日時 2018-06-05 10:12:35
言語 Kotlin
(1.9.23)
結果
WA  
実行時間 -
コード長 810 bytes
コンパイル時間 10,850 ms
コンパイル使用メモリ 449,380 KB
実行使用メモリ 98,940 KB
最終ジャッジ日時 2024-04-30 18:37:34
合計ジャッジ時間 21,162 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 324 ms
64,484 KB
testcase_01 AC 317 ms
98,940 KB
testcase_02 AC 301 ms
62,460 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 TLE -
testcase_10 TLE -
testcase_11 TLE -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.kt:3:10: warning: parameter 'args' is never used
fun main(args: Array<String>) {
         ^
Main.kt:14:96: warning: unnecessary non-null assertion (!!) on a non-null receiver of type Long
            _dp[k] = arrayOf(dp[k]+q[i][0], dp[k-1]+q[i][1], dp[k-2]+q[i][2], dp[k-3]+1L).min()!!
                                                                                               ^
Main.kt:16:88: warning: unnecessary non-null assertion (!!) on a non-null receiver of type Long
        if (P >= 2) _dp[2] = arrayOf(dp[2]+q[i][0], dp[1]+q[i][1], dp[0]+q[i][2]).min()!!
                                                                                       ^

ソースコード

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())})
    var dp = Array(P+1, { 0L })
    val inf = 100000L*N
    val filled_dp = Array(P+1, { inf })
    for (i in 0 until N) {
        val _dp = filled_dp.clone()
        for (k in Math.min(3*(i+1), P) downTo 3) {
            println(k)
            _dp[k] = arrayOf(dp[k]+q[i][0], dp[k-1]+q[i][1], dp[k-2]+q[i][2], dp[k-3]+1L).min()!!
        }
        if (P >= 2) _dp[2] = arrayOf(dp[2]+q[i][0], dp[1]+q[i][1], dp[0]+q[i][2]).min()!!
        if (P >= 1) _dp[1] = Math.min(dp[1]+q[i][0], dp[0]+q[i][1])
        _dp[0] = dp[0]+q[i][0]
        dp = _dp
    }
    println(dp[P].toDouble() / N.toDouble())
}
0