結果

問題 No.1183 コイン遊び
ユーザー risujiroh
提出日時 2020-08-22 13:02:44
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 197 ms / 2,000 ms
コード長 643 bytes
コンパイル時間 4,291 ms
コンパイル使用メモリ 250,672 KB
最終ジャッジ日時 2025-01-13 06:59:15
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 32
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/extc++.h>

#ifndef DUMP
#define DUMP(...) (void)0
#endif

using namespace std;

template <class S>
auto rle(const S& s) {
  vector<pair<typename S::value_type, int>> res;
  for (auto c : s)
    if (empty(res) or res.back().first != c)
      res.emplace_back(c, 1);
    else
      ++res.back().second;
  return res;
}

int main() {
  cin.tie(nullptr)->sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> a(n), b(n), c(n);
  for (auto&& e : a) cin >> e;
  for (auto&& e : b) cin >> e;
  for (int i = 0; i < n; ++i) c[i] = a[i] != b[i];
  int res = 0;
  for (auto [x, y] : rle(c))
    if (x) ++res;
  cout << res << '\n';
}
0