結果

問題 No.1183 コイン遊び
ユーザー yukudoyukudo
提出日時 2020-08-22 15:52:25
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 187 ms / 2,000 ms
コード長 1,216 bytes
コンパイル時間 1,451 ms
コンパイル使用メモリ 169,492 KB
実行使用メモリ 31,980 KB
最終ジャッジ日時 2024-04-23 10:08:31
合計ジャッジ時間 7,052 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 AC 1 ms
6,944 KB
testcase_04 AC 2 ms
6,944 KB
testcase_05 AC 1 ms
6,940 KB
testcase_06 AC 2 ms
6,940 KB
testcase_07 AC 1 ms
6,940 KB
testcase_08 AC 2 ms
6,940 KB
testcase_09 AC 2 ms
6,940 KB
testcase_10 AC 5 ms
6,940 KB
testcase_11 AC 13 ms
6,940 KB
testcase_12 AC 116 ms
19,624 KB
testcase_13 AC 104 ms
18,452 KB
testcase_14 AC 168 ms
23,064 KB
testcase_15 AC 180 ms
23,472 KB
testcase_16 AC 181 ms
25,004 KB
testcase_17 AC 180 ms
23,620 KB
testcase_18 AC 180 ms
24,212 KB
testcase_19 AC 182 ms
23,556 KB
testcase_20 AC 180 ms
24,064 KB
testcase_21 AC 156 ms
15,004 KB
testcase_22 AC 159 ms
15,064 KB
testcase_23 AC 157 ms
15,076 KB
testcase_24 AC 154 ms
15,140 KB
testcase_25 AC 183 ms
23,708 KB
testcase_26 AC 182 ms
23,696 KB
testcase_27 AC 182 ms
24,536 KB
testcase_28 AC 182 ms
23,760 KB
testcase_29 AC 155 ms
15,096 KB
testcase_30 AC 171 ms
31,980 KB
testcase_31 AC 184 ms
23,996 KB
testcase_32 AC 181 ms
24,136 KB
testcase_33 AC 187 ms
23,688 KB
testcase_34 AC 178 ms
23,572 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}

ll nextLong() { ll x; scanf("%lld", &x); return x;}


template<class T>
vector<pair<T, ll>> runLength(const vector<T>& xs) {
  vector<pair<T, ll>> res;
  for (auto x : xs) {
    if (res.empty() || res.back().first != x) {
      res.push_back({x, 1});
    } else {
      ++res.back().second;
    }
  }
  return res;
}


int main2() {
  int N = nextLong();
  vector<int> a(N), b(N), c(N);
  REP(i, N) a[i] = nextLong();
  REP(i, N) b[i] = nextLong();
  REP(i, N) c[i] = a[i] != b[i];
  auto r = runLength(c);

  int ans = 0;
  REP(i, r.size()) if (r[i].first == 1) ans++;
  cout << ans << endl;
  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}
0