結果

問題 No.79 過小評価ダメ・ゼッタイ
ユーザー Eclair1015
提出日時 2018-07-10 20:23:04
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 17 ms / 5,000 ms
コード長 449 bytes
コンパイル時間 563 ms
コンパイル使用メモリ 61,228 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-09-13 19:26:44
合計ジャッジ時間 1,989 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 22
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:26:17: warning: ‘memo’ may be used uninitialized in this function [-Wmaybe-uninitialized]
   26 |         cout << memo << endl;
      |                 ^~~~

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <vector>
#include<string>

using namespace std;
int main(){
	int n,maxv=0,memo;
	cin >> n;
	vector<int> a(n);
	vector<int> b(7);
	for (int i = 0; i < n; i++) cin >> a[i];
	
	for (int i = 0; i < n; i++) {
		b[a[i]]++;
	}

	for (int i = 1; i < 7; i++) {
		if (max(maxv, b[i]) == b[i]) {
			memo = i;
			maxv = b[i];
		}else if (maxv == b[i]) {
			memo = i;
		}
	}
	cout << memo << endl;
	return 0;
}

0