結果
| 問題 | No.628 Tagの勢い | 
| コンテスト | |
| ユーザー |  💕💖💞 | 
| 提出日時 | 2018-02-16 02:09:07 | 
| 言語 | Kotlin (2.1.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 501 ms / 2,000 ms | 
| コード長 | 872 bytes | 
| コンパイル時間 | 14,758 ms | 
| コンパイル使用メモリ | 440,956 KB | 
| 実行使用メモリ | 65,800 KB | 
| 最終ジャッジ日時 | 2024-11-20 13:47:52 | 
| 合計ジャッジ時間 | 19,911 ms | 
| ジャッジサーバーID (参考情報) | judge1 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 19 | 
コンパイルメッセージ
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:18:18: warning: parameter 'i' is never used, could be renamed to _
  }.mapIndexed { i, pair ->
                 ^
Main.kt:28: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
    if( freq_list.get(freq) == null )
      freq_list[freq] = mutableListOf<String>()
    freq_list[freq]!!.add( "${word} ${freq}" )
  }
  freq_list.toList().sortedBy { 
    it.first * -1
  }.map { 
    val (freq, list) = it
    list.sortedBy { 
      it
    }
  }.flatten().mapIndexed { index, it ->
    if( index <= 9 )
      println(it)
  }
}
            
            
            
        