結果

問題 No.921 ずんだアロー
ユーザー m1025o1184tm1025o1184t
提出日時 2019-11-15 18:10:23
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 846 bytes
コンパイル時間 1,950 ms
コンパイル使用メモリ 173,968 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-25 03:41:13
合計ジャッジ時間 4,260 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
typedef long long ll;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	vector<int> A(n);
	rep(i, n) cin >> A[i];
	int ans1 = 0;
	vector<bool> elf;
	if (A[0] != A[1]) elf.push_back(true);
	else elf.push_back(false);
	for (int i = 1; i < n; ++i) {
		if (A[i] == A[i - 1]) {
			ans1++;
			elf[elf.size() - 1] = false;
		}
		else {
			elf.push_back(true);
		}
	}
	int ans = 0;
	rep(i, elf.size()) {
		if (!elf[i]) ans++;
	}
	//over3
	for (int i = 2; i < elf.size(); ++i) {
		if (elf[i - 2] && elf[i - 1] && elf[i]) {
			ans++;
			elf[i] = false;
		}
	}
	//edge2
	int k = elf.size();
	if (elf[0] && elf[1]) ans++;
	if (elf[k - 2] && elf[k - 1]) ans++;
	ans += ans1;
	cout << ans << endl;
	return 0;
}
0