結果
| 問題 | No.17 2つの地点に泊まりたい | 
| コンテスト | |
| ユーザー |  バカらっく | 
| 提出日時 | 2019-09-01 12:29:54 | 
| 言語 | Kotlin (2.1.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 425 ms / 5,000 ms | 
| コード長 | 1,878 bytes | 
| コンパイル時間 | 16,121 ms | 
| コンパイル使用メモリ | 448,080 KB | 
| 実行使用メモリ | 54,396 KB | 
| 最終ジャッジ日時 | 2024-11-27 20:49:49 | 
| 合計ジャッジ時間 | 27,047 ms | 
| ジャッジサーバーID (参考情報) | judge2 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 27 | 
コンパイルメッセージ
Main.kt:1:10: warning: parameter 'args' is never used
fun main(args: Array<String>) {
         ^
            
            ソースコード
fun main(args: Array<String>) {
    val pointCount = readLine()!!.toInt()
    road = arrayOfNulls(pointCount)
    for(i in 1..pointCount) {
        feeList.add(readLine()!!.toInt())
        road[i-1] = arrayOfNulls<Int>(pointCount)
        road[i-1]!![i-1] = 0
    }
    val roadCount = readLine()!!.toInt()
    for(i in 1..roadCount) {
        val (a,b,c) = readLine()!!.split(" ").map { it.toInt() }
        road[a]!![b] = c
        road[b]!![a] = c
    }
    for(i in road.indices) {
        for(j in road.indices) {
            for(k in road.indices) {
                val express = road[j]!![k]
                road[j]!![i]?.let {
                    val part1 = it
                    road[i]!![k]?.let {
                        val part2 = it
                        express?.also {
                            if(express > part1 + part2) {
                                road[j]!![k] = part1 + part2
                            }
                        } ?: run {
                            road[j]!![k] = part1 + part2
                        }
                    }
                }
            }
        }
    }
    var ans = feeList.sum() + road.map { it!!.filter { it != null }.map { it!!.toLong() }.sum() }.sum()
    for(i in 1..pointCount - 2) {
        if(road[0]!![i] == null) {
            continue
        }
        for(j in 1..pointCount - 2) {
            if(i == j) {
                continue
            }
            if(road[i]!![j] == null) {
                continue
            }
            if(road[j]!![pointCount-1] == null) {
                continue
            }
            val subTotal = road[0]!![i]!! + feeList[i] + road[i]!![j]!! + feeList[j] + road[j]!![pointCount-1]!!
            ans = Math.min(ans, subTotal.toLong())
        }
    }
    println(ans)
}
var feeList = mutableListOf<Int>()
var road = arrayOfNulls<Array<Int?>>(0)
            
            
            
        