結果

問題 No.1183 コイン遊び
ユーザー yukudoyukudo
提出日時 2020-08-22 15:52:25
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 172 ms / 2,000 ms
コード長 1,216 bytes
コンパイル時間 1,496 ms
コンパイル使用メモリ 170,264 KB
実行使用メモリ 31,500 KB
最終ジャッジ日時 2023-08-05 12:55:38
合計ジャッジ時間 7,289 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,384 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 5 ms
4,376 KB
testcase_11 AC 12 ms
4,456 KB
testcase_12 AC 109 ms
19,956 KB
testcase_13 AC 100 ms
18,708 KB
testcase_14 AC 160 ms
23,104 KB
testcase_15 AC 168 ms
24,628 KB
testcase_16 AC 163 ms
24,084 KB
testcase_17 AC 167 ms
23,756 KB
testcase_18 AC 168 ms
23,268 KB
testcase_19 AC 164 ms
23,576 KB
testcase_20 AC 162 ms
24,368 KB
testcase_21 AC 140 ms
14,624 KB
testcase_22 AC 139 ms
14,784 KB
testcase_23 AC 138 ms
14,768 KB
testcase_24 AC 135 ms
14,820 KB
testcase_25 AC 165 ms
24,784 KB
testcase_26 AC 166 ms
24,136 KB
testcase_27 AC 172 ms
23,676 KB
testcase_28 AC 169 ms
23,520 KB
testcase_29 AC 143 ms
14,716 KB
testcase_30 AC 152 ms
31,500 KB
testcase_31 AC 170 ms
24,648 KB
testcase_32 AC 170 ms
23,560 KB
testcase_33 AC 172 ms
23,008 KB
testcase_34 AC 168 ms
23,424 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