結果

問題 No.79 過小評価ダメ・ゼッタイ
ユーザー toshiro_yanagi
提出日時 2019-01-06 22:40:07
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 17 ms / 5,000 ms
コード長 375 bytes
コンパイル時間 746 ms
コンパイル使用メモリ 71,572 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-11-24 00:19:13
合計ジャッジ時間 1,560 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 22
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function 'int main()':
main.cpp:30:17: warning: 'ans' may be used uninitialized [-Wmaybe-uninitialized]
   30 |         cout << ans << endl;
      |                 ^~~
main.cpp:20:13: note: 'ans' was declared here
   20 |         int ans;
      |             ^~~

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main()
{
	const int levels = 6;
	int n;
	cin >> n;
	vector<int> L(levels);

	for (int i = 0; i < n; i++)
	{
		int j;
		cin >> j;
		L[--j]++;
	}

	int ans;
	int max = 0;
	for (int i = 0; i < levels; i++)
	{
		if (max <= L[i])
		{
			max = L[i];
			ans = i + 1;
		}
	}
	cout << ans << endl;
}
0