結果
| 問題 |
No.628 Tagの勢い
|
| コンテスト | |
| ユーザー |
💕💖💞
|
| 提出日時 | 2018-02-16 02:04:58 |
| 言語 | Kotlin (2.1.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 889 bytes |
| コンパイル時間 | 12,077 ms |
| コンパイル使用メモリ | 439,004 KB |
| 実行使用メモリ | 65,792 KB |
| 最終ジャッジ日時 | 2024-11-20 13:45:56 |
| 合計ジャッジ時間 | 20,145 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 16 WA * 3 |
コンパイルメッセージ
Main.kt:1:10: warning: parameter 'args' is never used
fun main(args:Array<String>) {
^
Main.kt:6:10: warning: variable 'num' is never used
val (num, score) = readLine()!!.split(" ").map { it.toInt() }
^
Main.kt:33:10: warning: variable 'freq' is never used
val (freq, list) = it
^
ソースコード
fun main(args:Array<String>) {
val n = readLine()!!.toInt()
val map = mutableMapOf<String, Int>()
(1..n).map {
readLine()
val (num, score) = readLine()!!.split(" ").map { it.toInt() }
val words = readLine()!!.split(" ")
words.map { word ->
if(map.get(word) == null)
map[word] = 0
map[word] = map[word]!! + score
}
}
val freq_list = mutableMapOf<Int, MutableList<String>>()
map.toList().sortedBy {
it.second * -1
}.mapIndexed { i, pair ->
val (word, freq) = pair
when {
i <= 9 -> {
if( freq_list.get(freq) == null )
freq_list[freq] = mutableListOf<String>()
freq_list[freq]!!.add( "${word} ${freq}" )
}
else -> null
}
}
freq_list.toList().sortedBy {
it.first * -1
}.map {
val (freq, list) = it
list.sortedBy {
it
}.map { println(it) }
}
}
💕💖💞