結果

問題 No.3039 配信者
ユーザー pengin_2000
提出日時 2025-02-28 21:42:32
言語 C
(gcc 13.3.0)
結果
AC  
実行時間 212 ms / 2,000 ms
コード長 441 bytes
コンパイル時間 218 ms
コンパイル使用メモリ 25,856 KB
実行使用メモリ 13,292 KB
最終ジャッジ日時 2025-02-28 21:42:45
合計ジャッジ時間 3,605 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 15
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c: In function ‘main’:
main.c:7:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    7 |         scanf("%d %d", &n, &h);
      |         ^~~~~~~~~~~~~~~~~~~~~~
main.c:10:17: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   10 |                 scanf("%d %d", &a[i], &b[i]);
      |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~

ソースコード

diff #

#include<stdio.h>
int a[1000006], b[1000006];
int cnt[1000006];
int main()
{
	int n, h;
	scanf("%d %d", &n, &h);
	int i;
	for (i = 0; i < n; i++)
		scanf("%d %d", &a[i], &b[i]);
	for (i = 0; i <= h; i++)
		cnt[i] = 0;
	for (i = 0; i < n; i++)
	{
		cnt[a[i]]++;
		cnt[++b[i]]--;
	}
	for (i = 1; i <= h; i++)
		cnt[i] += cnt[i - 1];
	int ans = 0;
	for (i = 0; i < h; i++)
		if (ans < cnt[i])
			ans = cnt[i];
	printf("%d\n", ans);
	return 0;
}
0