結果

問題 No.1032 数数え
ユーザー tentententen
提出日時 2020-09-28 14:32:47
言語 Java21
(openjdk 21)
結果
AC  
実行時間 812 ms / 2,000 ms
コード長 490 bytes
コンパイル時間 3,777 ms
コンパイル使用メモリ 72,504 KB
実行使用メモリ 69,124 KB
最終ジャッジ日時 2023-09-14 20:49:24
合計ジャッジ時間 6,814 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 128 ms
56,044 KB
testcase_01 AC 128 ms
55,708 KB
testcase_02 AC 129 ms
55,780 KB
testcase_03 AC 128 ms
56,468 KB
testcase_04 AC 128 ms
56,140 KB
testcase_05 AC 128 ms
55,712 KB
testcase_06 AC 127 ms
55,696 KB
testcase_07 AC 812 ms
69,124 KB
testcase_08 AC 134 ms
56,128 KB
testcase_09 AC 204 ms
56,432 KB
testcase_10 AC 188 ms
57,668 KB
testcase_11 AC 128 ms
55,984 KB
testcase_12 AC 790 ms
68,004 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();
		int[] counts = new int[m + 1];
		for (int i = 0; i < n; i++) {
		    int x = sc.nextInt();
		    if (x <= m) {
		        counts[x]++;
		    }
		}
		StringBuilder sb = new StringBuilder();
		for (int i = 1; i <= m; i++) {
		    sb.append(i).append(" ").append(counts[i]).append("\n");
		}
		System.out.print(sb);
	}
}
0