結果

問題 No.1032 数数え
ユーザー yomo3yomo3
提出日時 2020-05-07 23:17:21
言語 Java21
(openjdk 21)
結果
AC  
実行時間 1,064 ms / 2,000 ms
コード長 742 bytes
コンパイル時間 2,313 ms
コンパイル使用メモリ 77,716 KB
実行使用メモリ 85,308 KB
最終ジャッジ日時 2023-09-16 08:10:48
合計ジャッジ時間 7,309 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 163 ms
56,884 KB
testcase_01 AC 162 ms
56,644 KB
testcase_02 AC 168 ms
56,860 KB
testcase_03 AC 163 ms
57,144 KB
testcase_04 AC 164 ms
56,604 KB
testcase_05 AC 162 ms
56,804 KB
testcase_06 AC 165 ms
56,836 KB
testcase_07 AC 1,064 ms
85,308 KB
testcase_08 AC 174 ms
57,240 KB
testcase_09 AC 289 ms
59,816 KB
testcase_10 AC 210 ms
57,304 KB
testcase_11 AC 168 ms
56,528 KB
testcase_12 AC 975 ms
68,216 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
import java.io.PrintWriter;

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);
		PrintWriter pw = new PrintWriter(System.out);
		for (int i = 1; i <= M; i++) {
			pw.println(i + " " + m.getOrDefault(i, 0));
		}
		pw.flush();
    }
}
0