結果

問題 No.1183 コイン遊び
ユーザー yorry2101
提出日時 2023-06-22 14:44:53
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 383 ms / 2,000 ms
コード長 566 bytes
コンパイル時間 850 ms
コンパイル使用メモリ 72,064 KB
最終ジャッジ日時 2025-02-15 00:08:26
ジャッジサーバーID
(参考情報)
judge7 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 32
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
using namespace std;
int main(void){
    int n;
    cin >> n;
    vector<int> a(n), b(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    for (int i = 0; i < n; i++) {
        cin >> b[i];
    }
    
    bool msrng = (a[0] != b[0]);
    int cnt = 0;
    for (int i = 0; i < n; i++) {
        if (a[i] == b[i] && msrng) {
            msrng = false;
            cnt++;
        }
        else if (a[i] != b[i] && !msrng) {
            msrng = true;
        }
    }
    if (msrng) cnt++;
    cout << cnt << endl;
}
0