結果

問題 No.79 過小評価ダメ・ゼッタイ
ユーザー toto
提出日時 2025-03-27 17:18:49
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 13 ms / 5,000 ms
コード長 370 bytes
コンパイル時間 391 ms
コンパイル使用メモリ 27,776 KB
実行使用メモリ 5,888 KB
最終ジャッジ日時 2025-03-27 17:18:50
合計ジャッジ時間 1,657 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 22
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:8:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    8 |         scanf("%d",&val);
      |         ~~~~~^~~~~~~~~~~
main.cpp:12:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   12 |                 scanf("%d",&tmp);
      |                 ~~~~~^~~~~~~~~~~

ソースコード

diff #

#include <stdio.h>

int main(){
	int ans[6] = {0,0,0,0,0,0};
	
	// 投票数
	int val = 0;
	scanf("%d",&val);
	// 種類別に分ける
	for(int i = 0;i < val;i ++){
		int tmp = 0;
		scanf("%d",&tmp);
		ans[tmp - 1]++;
	}
	
	int max = 0;
	int result = 0;
	for(int i = 0;i < 6;i ++){
		if(max <= ans[i]){
			max = ans[i];
			result = i + 1;
		}
	}
	printf("%d",result);
}
0