結果
問題 | No.90 品物の並び替え |
ユーザー | komkomh |
提出日時 | 2019-04-25 14:19:56 |
言語 | Kotlin (1.9.23) |
結果 |
AC
|
実行時間 | 2,138 ms / 5,000 ms |
コード長 | 726 bytes |
コンパイル時間 | 13,946 ms |
コンパイル使用メモリ | 421,844 KB |
実行使用メモリ | 71,372 KB |
最終ジャッジ日時 | 2023-08-13 01:49:23 |
合計ジャッジ時間 | 22,092 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge11 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 337 ms
57,312 KB |
testcase_01 | AC | 812 ms
65,924 KB |
testcase_02 | AC | 331 ms
57,576 KB |
testcase_03 | AC | 567 ms
63,656 KB |
testcase_04 | AC | 541 ms
61,952 KB |
testcase_05 | AC | 815 ms
67,340 KB |
testcase_06 | AC | 806 ms
64,584 KB |
testcase_07 | AC | 368 ms
57,576 KB |
testcase_08 | AC | 325 ms
57,704 KB |
testcase_09 | AC | 2,138 ms
71,372 KB |
コンパイルメッセージ
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()) }