結果

問題 No.706 多眼生物の調査
ユーザー GBGB
提出日時 2018-09-23 20:34:34
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 11 ms / 2,000 ms
コード長 907 bytes
コンパイル時間 672 ms
コンパイル使用メモリ 74,200 KB
実行使用メモリ 4,352 KB
最終ジャッジ日時 2023-10-12 15:57:33
合計ジャッジ時間 1,387 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,348 KB
testcase_01 AC 1 ms
4,352 KB
testcase_02 AC 1 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,352 KB
testcase_05 AC 5 ms
4,352 KB
testcase_06 AC 11 ms
4,352 KB
testcase_07 AC 2 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

using namespace std;

int main() {

	//nを入力
	//おおきさnの配列を定義
	
	//文字列sを入力
	//'^'の数を数えて、数に対応する配列のindexに格納する
	//これをn回繰り返す

	//配列に格納されている値が最も大きいものを選ぶ
	//文字同列ならばindexの大きいほうを出力する
	//そのindexを出力する

	int n;
	vector<int> array;
	cin >> n;
	array.resize(1001,0);

	string str;
	int count=0;
	for (int i = 0;i < n;i++) {
		count = 0;
		cin >> str;
		for (int j = 0;j < str.size();j++) {
			if (str[j] == '^')count++;
		}
		array[count]++;
	}
	
	int maxa = 0;
	for (int i = 1;i <= array.size() - 2;i++) {
		if (array[i+1]!=0 && array[i] <= array[i + 1]) {
			if (array[maxa]<=array[i+1]) {
				maxa = i + 1;
			}
		}
	}

	cout << maxa << endl;

	return 0;
}
0