結果
問題 | No.90 品物の並び替え |
ユーザー | komkomh |
提出日時 | 2019-04-25 14:19:56 |
言語 | Kotlin (1.9.23) |
結果 |
TLE
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 726 bytes |
コンパイル時間 | 13,839 ms |
コンパイル使用メモリ | 443,824 KB |
実行使用メモリ | 151,644 KB |
最終ジャッジ日時 | 2024-04-30 20:22:46 |
合計ジャッジ時間 | 26,700 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 352 ms
60,688 KB |
testcase_01 | AC | 917 ms
97,104 KB |
testcase_02 | AC | 345 ms
60,632 KB |
testcase_03 | AC | 568 ms
77,184 KB |
testcase_04 | AC | 553 ms
75,532 KB |
testcase_05 | AC | 862 ms
99,260 KB |
testcase_06 | AC | 883 ms
94,588 KB |
testcase_07 | AC | 389 ms
62,760 KB |
testcase_08 | AC | 349 ms
60,772 KB |
testcase_09 | TLE | - |
コンパイルメッセージ
Main.kt:12:85: warning: 'sumBy((T) -> Int): Int' is deprecated. Use sumOf instead. return scores.filter { itemMap.get(it.first)!! < itemMap.get(it.second)!! }.sumBy { it.third } ^ Main.kt:17:98: warning: unnecessary non-null assertion (!!) on a non-null receiver of type Int false -> (0 until n).filter { !items.contains(it) }.map { getMaxScore(*items, it) }.max()!! ^
ソースコード
package yukicoder fun main() { val (n, m) = readLine()!!.split(" ").map(String::toInt) val scores = (0 until m).map { val (item1, item2, score) = readLine()!!.split(" ").map(String::toInt) Triple(item1, item2, score) } fun getScore(items: IntArray): Int { val itemMap: Map<Int, Int> = items.mapIndexed { index, i -> i to index }.toMap() return scores.filter { itemMap.get(it.first)!! < itemMap.get(it.second)!! }.sumBy { it.third } } fun getMaxScore(vararg items: Int): Int = when (items.size >= n) { true -> getScore(items) false -> (0 until n).filter { !items.contains(it) }.map { getMaxScore(*items, it) }.max()!! } println(getMaxScore()) }