結果

問題 No.1183 コイン遊び
ユーザー forest3
提出日時 2020-12-03 22:13:04
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 317 ms / 2,000 ms
コード長 568 bytes
コンパイル時間 1,513 ms
コンパイル使用メモリ 169,408 KB
実行使用メモリ 11,132 KB
最終ジャッジ日時 2024-09-14 07:33:36
合計ジャッジ時間 11,390 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 32
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main()
{
	int N;
	cin >> N;
	vector<int> A( N );
	for( int i = 0; i < N; i++ ) {
		cin >> A[i];
	}
	vector<int> B( N );
	for( int i = 0; i < N; i++ ) {
		cin >> B[i];
	}

	int ans = 0;
	int same = -1;
	for( int i = 0; i < N; i++ ) {
		if( same < 0 ) {
			if( A[i] == B[i] ) same = 1;
			else same = 0;
		}
		else if( same ) {
			if( A[i] == B[i] ) same = 1;
			else same = 0;
		}
		else {
			if( A[i] == B[i] ) {
				ans++;
				same = 1;
			}
			else same = 0;
		}
	}
	if( same == 0 ) ans++;

	cout << ans << endl;
}
0