結果

問題 No.628 Tagの勢い
ユーザー 💕💖💞💕💖💞
提出日時 2018-02-16 02:04:58
言語 Kotlin
(1.9.23)
結果
WA  
実行時間 -
コード長 889 bytes
コンパイル時間 15,099 ms
コンパイル使用メモリ 446,056 KB
実行使用メモリ 65,868 KB
最終ジャッジ日時 2024-04-30 16:53:43
合計ジャッジ時間 22,079 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 336 ms
60,640 KB
testcase_01 AC 341 ms
60,660 KB
testcase_02 AC 332 ms
60,616 KB
testcase_03 AC 342 ms
60,744 KB
testcase_04 AC 313 ms
57,028 KB
testcase_05 AC 334 ms
60,696 KB
testcase_06 AC 337 ms
60,628 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 357 ms
60,792 KB
testcase_11 AC 349 ms
60,592 KB
testcase_12 AC 499 ms
65,756 KB
testcase_13 AC 505 ms
65,848 KB
testcase_14 AC 488 ms
65,868 KB
testcase_15 AC 482 ms
65,740 KB
testcase_16 AC 406 ms
63,128 KB
testcase_17 AC 338 ms
60,520 KB
testcase_18 AC 338 ms
60,724 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
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
         ^

ソースコード

diff #

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