結果

問題 No.1183 コイン遊び
ユーザー a01sa01to
提出日時 2024-10-10 00:25:06
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 360 ms / 2,000 ms
コード長 679 bytes
コンパイル時間 3,603 ms
コンパイル使用メモリ 248,864 KB
実行使用メモリ 19,536 KB
最終ジャッジ日時 2024-10-10 00:25:20
合計ジャッジ時間 13,489 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 32
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
  #include "settings/debug.cpp"
#else
  #define Debug(...) void(0)
#endif
#define rep(i, n) for (int i = 0; i < (n); ++i)
using ll = long long;
using ull = unsigned long long;

int main() {
  int n;
  cin >> n;
  vector<int> a(n), b(n);
  rep(i, n) cin >> a[i];
  rep(i, n) cin >> b[i];
  vector<pair<bool, int>> rle(1, { a[0] == b[0], 0 });
  rep(i, n) {
    bool state = a[i] == b[i];
    if (rle.back().first == state) {
      rle.back().second++;
    }
    else {
      rle.push_back({ state, 1 });
    }
  }
  int ans = 0;
  for (auto [state, len] : rle)
    if (!state) ans++;
  cout << ans << endl;
  return 0;
}
0