結果

問題 No.1130 Grid Numbers
ユーザー face4face4
提出日時 2020-08-02 12:11:30
言語 Java21
(openjdk 21)
結果
AC  
実行時間 56 ms / 2,000 ms
コード長 876 bytes
コンパイル時間 3,624 ms
コンパイル使用メモリ 75,372 KB
実行使用メモリ 49,764 KB
最終ジャッジ日時 2023-09-25 13:24:40
合計ジャッジ時間 4,324 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 44 ms
49,500 KB
testcase_01 AC 46 ms
49,540 KB
testcase_02 AC 44 ms
49,604 KB
testcase_03 AC 44 ms
49,448 KB
testcase_04 AC 44 ms
49,624 KB
testcase_05 AC 46 ms
49,480 KB
testcase_06 AC 45 ms
49,628 KB
testcase_07 AC 45 ms
49,764 KB
testcase_08 AC 46 ms
49,492 KB
testcase_09 AC 52 ms
49,608 KB
testcase_10 AC 56 ms
49,748 KB
testcase_11 AC 51 ms
49,528 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;
import java.util.ArrayList;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] line = br.readLine().split(" ");
        int h = Integer.parseInt(line[0]), w = Integer.parseInt(line[1]);
        ArrayList<Integer> arr = new ArrayList<Integer>(h * w);
        for (int i = 0; i < h; i++) {
            line = br.readLine().split(" ");
            for (int j = 0; j < w; j++) {
                arr.add(Integer.parseInt(line[j]));
            }
        }
        arr.sort(null);
        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                if (j > 0) System.out.print(" ");
                System.out.print(arr.get(i * w + j));
            }
            System.out.println();
        }
    }
}
0