結果

問題 No.647 明太子
ユーザー toto
提出日時 2025-03-28 14:46:12
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 33 ms / 4,500 ms
コード長 805 bytes
コンパイル時間 389 ms
コンパイル使用メモリ 29,280 KB
実行使用メモリ 7,328 KB
最終ジャッジ日時 2025-03-28 14:46:13
合計ジャッジ時間 1,736 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 20
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:5:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    5 |         scanf("%d", &people);
      |         ~~~~~^~~~~~~~~~~~~~~
main.cpp:8:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    8 |                 scanf("%d %d", &price1[i], &spice1[i]);
      |                 ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
main.cpp:12:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   12 |         scanf("%d", &type);
      |         ~~~~~^~~~~~~~~~~~~
main.cpp:15:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   15 |                 scanf("%d %d", &price2[i], &spice2[i]);
      |                 ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

ソースコード

diff #

#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