結果

問題 No.647 明太子
コンテスト
ユーザー toto
提出日時 2025-03-28 14:46:12
言語 C++17
(gcc 15.2.0 + boost 1.90.0)
コンパイル:
g++-15 -O2 -lm -std=c++17 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 26 ms / 4,500 ms
コード長 805 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 115 ms
コンパイル使用メモリ 41,432 KB
実行使用メモリ 9,200 KB
最終ジャッジ日時 2026-07-08 00:11:11
合計ジャッジ時間 1,484 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include<stdio.h>
int main()
{
	int people;
	scanf("%d", &people);
	int price1[people], spice1[people];
	for (int i = 0; i < people; i++){
		scanf("%d %d", &price1[i], &spice1[i]);
	}
	
	int type;
	scanf("%d", &type);
	int price2[type], spice2[type];
	for (int i = 0; i < type; i++){
		scanf("%d %d", &price2[i], &spice2[i]);
	}
	
	int count[type];
	for (int i = 0; i < type; i++){
		count[i] = 0;	
	}
	
	for (int i = 0; i < people; i++){
		for (int j = 0; j < type; j++){
			if (price2[j] <= price1[i] && spice2[j] >= spice1[i]){
				count[j]++;
			}
		}
	}
		
	int max = 0;
	for (int i = 0; i < type; i++){
		if (max < count[i]){
			max = count[i];
		}
	}
		
	if (max == 0){
		printf("0\n");
	}
	else
	{
		for (int i = 0; i < type; i++){
			if (count[i] == max){
				printf("%d\n", i + 1);
			}
		}
	}
}
0