結果
問題 | No.90 品物の並び替え |
ユーザー | komkomh |
提出日時 | 2019-04-24 17:19:38 |
言語 | Kotlin (1.9.23) |
結果 |
TLE
|
実行時間 | - |
コード長 | 710 bytes |
コンパイル時間 | 13,989 ms |
コンパイル使用メモリ | 445,228 KB |
実行使用メモリ | 189,216 KB |
最終ジャッジ日時 | 2024-04-30 20:23:39 |
合計ジャッジ時間 | 42,711 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 364 ms
63,932 KB |
testcase_01 | AC | 4,335 ms
189,216 KB |
testcase_02 | AC | 357 ms
60,420 KB |
testcase_03 | AC | 3,423 ms
151,284 KB |
testcase_04 | AC | 3,450 ms
150,988 KB |
testcase_05 | AC | 4,380 ms
150,944 KB |
testcase_06 | AC | 4,155 ms
151,104 KB |
testcase_07 | AC | 512 ms
70,556 KB |
testcase_08 | AC | 357 ms
60,528 KB |
testcase_09 | TLE | - |
コンパイルメッセージ
Main.kt:12:78: warning: 'sumBy((T) -> Int): Int' is deprecated. Use sumOf instead. scores.filter { items.indexOf(it.first) < items.indexOf(it.second) }.sumBy { it.third } ^ Main.kt:17:97: warning: unnecessary non-null assertion (!!) on a non-null receiver of type Int false -> (0..n).filter { !items.contains(it) }.map { getMaxScore(*items, it) }.max()!! ^
ソースコード
package yukicoder fun main() { val (n, m) = readLine()!!.split(" ").map(String::toInt) val scores = mutableSetOf<Triple<Int, Int, Int>>() (0 until m).forEach { val (item1, item2, score) = readLine()!!.split(" ").map(String::toInt) scores.add(Triple(item1, item2, score)) } fun getScore(items: IntArray): Int = scores.filter { items.indexOf(it.first) < items.indexOf(it.second) }.sumBy { it.third } fun getMaxScore(vararg items: Int): Int { return when (items.size >= n) { true -> getScore(items) false -> (0..n).filter { !items.contains(it) }.map { getMaxScore(*items, it) }.max()!! } } println(getMaxScore()) }