結果

問題 No.1032 数数え
ユーザー yomo3yomo3
提出日時 2020-05-07 23:12:43
言語 Java21
(openjdk 21)
結果
AC  
実行時間 1,010 ms / 2,000 ms
コード長 554 bytes
コンパイル時間 2,240 ms
コンパイル使用メモリ 80,536 KB
実行使用メモリ 85,704 KB
最終ジャッジ日時 2023-09-16 08:11:42
合計ジャッジ時間 7,109 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 162 ms
55,108 KB
testcase_01 AC 165 ms
57,164 KB
testcase_02 AC 162 ms
56,904 KB
testcase_03 AC 160 ms
56,604 KB
testcase_04 AC 158 ms
57,088 KB
testcase_05 AC 160 ms
56,860 KB
testcase_06 AC 161 ms
57,036 KB
testcase_07 AC 1,010 ms
85,704 KB
testcase_08 AC 174 ms
56,852 KB
testcase_09 AC 252 ms
59,668 KB
testcase_10 AC 200 ms
58,644 KB
testcase_11 AC 160 ms
56,728 KB
testcase_12 AC 880 ms
70,212 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        Map<Integer, Integer> m = new HashMap<>();
        for (int i = 0; i < N; i++) {
            m.merge(Integer.parseInt(sc.next()), 1, Integer::sum);
        }
        StringBuilder sb = new StringBuilder();
        for (int i = 1; i <= M; i++) {
            sb.append(i + " " + m.getOrDefault(i, 0) + '\n');
        }

        System.out.print(sb);
    }
}
0