結果

問題 No.628 Tagの勢い
ユーザー 👑 yumechiyumechi
提出日時 2021-03-04 02:25:09
言語 Scala(Beta)
(3.4.0)
結果
WA  
実行時間 -
コード長 769 bytes
コンパイル時間 12,294 ms
コンパイル使用メモリ 261,368 KB
実行使用メモリ 74,288 KB
最終ジャッジ日時 2024-04-14 21:46:27
合計ジャッジ時間 32,975 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,003 ms
66,876 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 AC 1,009 ms
66,772 KB
testcase_04 AC 973 ms
66,488 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 1,047 ms
67,284 KB
testcase_11 WA -
testcase_12 AC 1,356 ms
73,820 KB
testcase_13 WA -
testcase_14 AC 1,331 ms
71,980 KB
testcase_15 WA -
testcase_16 AC 1,202 ms
67,360 KB
testcase_17 WA -
testcase_18 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner

object Main extends App {
  val sc = new Scanner(System.in)

  val n = sc.nextInt
  var mp = Map.empty[String, Int]
  for(_ <- 0 until n) {
    val _ = sc.nextInt
    val m = sc.nextInt
    val s = sc.nextInt
    for(t <- Array.fill(m)(sc.next)) {
      val cs = mp.getOrElse(t, 0)
      mp += t -> (cs + s)
    }
  }
  val ta = mp.map(elem => Array(elem._1, elem._2)).toSeq
  val arr = ta.sortWith((t1, t2) => {
    if(t1(1).toString.toInt > t2(1).toString.toInt) {
      true
    } else if(t1(1).toString.toInt == t2(1).toString.toInt
              && t2(1).toString >= t1(0).toString) {
      true
    } else {
      false
    }
  })
  val limit = math.min(10, arr.length)
  for(i <- 0 until limit) {
    println(arr(i).mkString(" "))
  }
}
0