結果
| 問題 | No.561 東京と京都 |
| コンテスト | |
| ユーザー |
💕💖💞
|
| 提出日時 | 2017-09-08 18:00:17 |
| 言語 | Kotlin (2.3.20) |
| 結果 |
AC
|
| 実行時間 | 244 ms / 2,000 ms |
| コード長 | 1,090 bytes |
| 記録 | |
| コンパイル時間 | 9,470 ms |
| コンパイル使用メモリ | 482,516 KB |
| 実行使用メモリ | 59,272 KB |
| 最終ジャッジ日時 | 2026-05-14 14:23:12 |
| 合計ジャッジ時間 | 15,247 ms |
|
ジャッジサーバーID (参考情報) |
judge2_1 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 17 |
コンパイルメッセージ
Main.kt:33:35: warning: unnecessary non-null assertion (!!) on a non-null receiver of type 'Triple<Int, String, Int>'.
println( memo.maxBy { it.third }!!.third )
^^
ソースコード
typealias Money = Int
typealias Index = Int
typealias City = String
fun main( args : Array<String> ) {
val (n, d) = readLine()!!.split(" ").map { it.toInt() }
val tk = (1..n).map {
val (t,k) = readLine()!!.split(" ").map { it.toInt() }
Pair( Pair("T", t), Pair("K", k) )
}
val memo = mutableListOf<Triple<Index, City, Money>>( Triple(-1, "T", 0) )
tk.mapIndexed { i, tk_ ->
// search lastindex
val lastsAll = memo.filter { it.first == i-1 }.sortedBy { it.third * -1 }
val lasts = when {
lastsAll.size > 10 -> lastsAll.slice(0..9)
else -> lastsAll
}
// build next divercity
val (tokyo, kyoto) = tk_
lasts.map { last ->
if( last.second == tokyo.first ) {
memo.add( Triple(i, "T", last.third + tokyo.second) )
memo.add( Triple(i, "K", last.third + kyoto.second - d) )
}
if( last.second == kyoto.first ) {
memo.add( Triple(i, "T", last.third + tokyo.second - d) )
memo.add( Triple(i, "K", last.third + kyoto.second) )
}
}
}
println( memo.maxBy { it.third }!!.third )
}
💕💖💞