結果
問題 | No.17 2つの地点に泊まりたい |
ユーザー | バカらっく |
提出日時 | 2019-09-01 12:27:23 |
言語 | Kotlin (1.9.23) |
結果 |
RE
|
実行時間 | - |
コード長 | 1,856 bytes |
コンパイル時間 | 14,315 ms |
コンパイル使用メモリ | 449,724 KB |
実行使用メモリ | 53,872 KB |
最終ジャッジ日時 | 2024-05-05 19:59:25 |
合計ジャッジ時間 | 24,042 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 284 ms
51,796 KB |
testcase_01 | AC | 269 ms
51,484 KB |
testcase_02 | AC | 281 ms
51,816 KB |
testcase_03 | AC | 312 ms
53,272 KB |
testcase_04 | AC | 304 ms
51,976 KB |
testcase_05 | AC | 347 ms
53,380 KB |
testcase_06 | AC | 324 ms
52,160 KB |
testcase_07 | AC | 324 ms
52,436 KB |
testcase_08 | AC | 367 ms
53,712 KB |
testcase_09 | AC | 360 ms
53,872 KB |
testcase_10 | AC | 334 ms
53,372 KB |
testcase_11 | AC | 351 ms
53,784 KB |
testcase_12 | AC | 274 ms
51,560 KB |
testcase_13 | RE | - |
testcase_14 | RE | - |
testcase_15 | RE | - |
testcase_16 | RE | - |
testcase_17 | RE | - |
testcase_18 | RE | - |
testcase_19 | RE | - |
testcase_20 | RE | - |
testcase_21 | RE | - |
testcase_22 | RE | - |
testcase_23 | AC | 330 ms
53,312 KB |
testcase_24 | AC | 336 ms
53,380 KB |
testcase_25 | AC | 289 ms
51,808 KB |
testcase_26 | AC | 361 ms
53,596 KB |
コンパイルメッセージ
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!!.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)