結果

問題 No.472 平均順位
ユーザー htkb
提出日時 2018-06-05 08:55:37
言語 Kotlin
(2.1.0)
結果
TLE  
実行時間 -
コード長 654 bytes
コンパイル時間 14,002 ms
コンパイル使用メモリ 441,512 KB
実行使用メモリ 92,156 KB
最終ジャッジ日時 2024-11-20 16:04:10
合計ジャッジ時間 33,039 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 13 TLE * 3
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.kt:3:10: warning: parameter 'args' is never used
fun main(args: Array<String>) {
         ^
Main.kt:19:31: warning: unnecessary non-null assertion (!!) on a non-null receiver of type Long
    println(dp.take(P+1).min()!!.toDouble() / N.toDouble())
                              ^

ソースコード

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(), 1 )})
    var dp = Array(P+4, { 0L })
    val filled_dp = Array(P+4, { 100000000000L })
    for (i in 0 until N) {
        val max_n = 4*i
        val _dp: Array<Long> = filled_dp.clone()
        for (j in 0 until 4) {
            for (k in Math.min(max_n, P+3-j) downTo 0) {
                _dp[k+j] = Math.min(_dp[k+j], dp[k]+q[i][j])
            }
        }
        dp = _dp
    }
    println(dp.take(P+1).min()!!.toDouble() / N.toDouble())
}
0