結果

問題 No.1032 数数え
ユーザー QCFiumQCFium
提出日時 2020-04-23 20:14:53
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 12 ms / 2,000 ms
コード長 694 bytes
コンパイル時間 1,540 ms
コンパイル使用メモリ 162,436 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-21 22:17:12
合計ジャッジ時間 2,406 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 2 ms
6,944 KB
testcase_04 AC 2 ms
6,940 KB
testcase_05 AC 1 ms
6,944 KB
testcase_06 AC 2 ms
6,944 KB
testcase_07 AC 12 ms
6,940 KB
testcase_08 AC 2 ms
6,940 KB
testcase_09 AC 2 ms
6,944 KB
testcase_10 AC 2 ms
6,940 KB
testcase_11 AC 2 ms
6,944 KB
testcase_12 AC 11 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

char buf[2000000];
char *p = buf;
int ru() {
	int r = 0;
	while (*p < '0' || *p > '9') p++;
	while (*p >= '0' && *p <= '9') r = r * 10 + *p++ - '0';
	return r;
}
void write(int x) { // x >= 0
	static char tmp[10];
	char *tmpp = tmp;
	if (!x) *tmpp++ = '0';
	while (x) *tmpp++ = x % 10 + '0', x /= 10;
	while (tmpp > tmp) *p++ = *--tmpp;
}

int main() {
	fread(buf, sizeof(buf), 1, stdin);
	int n = ru();
	int m = ru();
	int res[m + 1] = { 0 };
	for (int i = 0; i < n; i++) {
		int x = ru();
		if (x <= m) res[x]++;
	}
	p = buf;
	for (int i = 1; i <= m; i++) {
		write(i);
		*p++ = ' ';
		write(res[i]);
		*p++ = '\n';
	}
	fwrite(buf, 1, p - buf, stdout);
	return 0;
}
0