結果

問題 No.628 Tagの勢い
コンテスト
ユーザー 💕💖💞
提出日時 2018-02-16 02:09:07
言語 Kotlin
(2.3.20)
コンパイル:
kotlinc _filename_ -include-runtime -d main.jar
実行:
kotlin main.jar
結果
AC  
実行時間 306 ms / 2,000 ms
コード長 872 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 9,889 ms
コンパイル使用メモリ 465,708 KB
実行使用メモリ 60,872 KB
最終ジャッジ日時 2026-05-14 16:15:08
合計ジャッジ時間 15,377 ms
ジャッジサーバーID
(参考情報)
judge2_1 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 19
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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)
  }
}
0