結果

問題 No.1130 Grid Numbers
ユーザー 👑 yumechiyumechi
提出日時 2021-02-24 00:06:13
言語 Scala(Beta)
(3.3.1)
結果
AC  
実行時間 1,012 ms / 2,000 ms
コード長 491 bytes
コンパイル時間 13,765 ms
コンパイル使用メモリ 272,032 KB
実行使用メモリ 66,288 KB
最終ジャッジ日時 2023-10-24 01:44:39
合計ジャッジ時間 26,599 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 993 ms
66,144 KB
testcase_01 AC 997 ms
66,204 KB
testcase_02 AC 993 ms
66,208 KB
testcase_03 AC 996 ms
66,140 KB
testcase_04 AC 988 ms
66,212 KB
testcase_05 AC 988 ms
66,212 KB
testcase_06 AC 992 ms
66,188 KB
testcase_07 AC 993 ms
66,216 KB
testcase_08 AC 988 ms
66,288 KB
testcase_09 AC 1,011 ms
66,244 KB
testcase_10 AC 1,012 ms
66,256 KB
testcase_11 AC 1,007 ms
66,272 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner

object Main extends App {
  def calc(ar: Array[Int], w: Int): Array[String] = {
    if(ar.length > w) {
      val f = ar.splitAt(w)
      Array(f._1.mkString(" ")).appendedAll(calc(f._2, w))
    } else {
      Array(ar.mkString(" "))
    }
  }

  val sc = new Scanner(System.in)

  val h = sc.nextInt
  val w = sc.nextInt
  val arr = Array.fill(h)(Array.fill(w)(sc.nextInt))
  val ar = arr.flatten.sorted

  println(calc(ar, w).map(_.mkString("")).mkString("\n"))
}
0