結果

問題 No.921 ずんだアロー
ユーザー polylogKpolylogK
提出日時 2019-09-12 18:36:57
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 959 bytes
コンパイル時間 1,810 ms
コンパイル使用メモリ 172,112 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-09-15 05:47:49
合計ジャッジ時間 2,741 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 WA -
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 2 ms
6,940 KB
testcase_04 AC 2 ms
6,940 KB
testcase_05 AC 2 ms
6,944 KB
testcase_06 AC 2 ms
6,944 KB
testcase_07 AC 1 ms
6,940 KB
testcase_08 AC 2 ms
6,940 KB
testcase_09 AC 2 ms
6,940 KB
testcase_10 AC 13 ms
6,944 KB
testcase_11 WA -
testcase_12 AC 5 ms
6,940 KB
testcase_13 AC 11 ms
6,944 KB
testcase_14 AC 12 ms
6,944 KB
testcase_15 AC 8 ms
6,944 KB
testcase_16 AC 3 ms
6,940 KB
testcase_17 AC 13 ms
6,944 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 15 ms
6,940 KB
testcase_24 AC 13 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = long long;
using std::cout;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

int main() {
	// input
	int n; scanf("%d", &n);
	assert(1 <= n and n <= (int)1e5);

	std::vector<int> a(n);
	for(int i = 0; i < n; i++) {
		scanf("%d", &a[i]);

		assert(1 <= a[i] and a[i] <= (int)1e5);
	}

	// solve
	std::vector<std::pair<int, int>> vec;
	for(int i = 0; i < n; i++) {
		if(vec.empty() or vec.back().first != a[i]) vec.push_back({a[i], 1});
		else vec.back().second++;
	}

	int ans = 0;
	for(int loop = 0; loop < 2; loop++) {
		int tmp = 0;
		for(int i = loop; i < vec.size(); i += 2) tmp += vec[i].second;
		ans = std::max(ans, tmp);
	}
	printf("%d\n", ans);
	return 0;
}
0