結果

問題 No.921 ずんだアロー
ユーザー startcpp
提出日時 2019-11-08 21:54:16
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 30 ms / 2,000 ms
コード長 404 bytes
コンパイル時間 405 ms
コンパイル使用メモリ 53,368 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-09-15 01:27:06
合計ジャッジ時間 1,701 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#define rep(i, n) for(i = 0; i < n; i++)
using namespace std;

int n;
int a[100000];
bool used[100000];

int main() {
	int i;
	
	cin >> n;
	rep(i, n) cin >> a[i];
	
	int cnt = 0;
	used[0] = true; cnt++;
	for (i = 1; i < n; i++) {
		if (a[i - 1] == a[i]) {
			used[i] = true; cnt++;
		}
		else {
			used[i] = !used[i - 1];
			cnt += used[i];
		}
	}
	
	cout << cnt << endl;
	return 0;
}
0