結果

問題 No.3114 0→1
ユーザー rurun
提出日時 2025-04-20 02:04:07
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 540 bytes
コンパイル時間 2,374 ms
コンパイル使用メモリ 197,092 KB
実行使用メモリ 7,848 KB
最終ジャッジ日時 2025-04-20 02:04:11
合計ジャッジ時間 2,726 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2 WA * 1
other WA * 30
権限があれば一括ダウンロードができます

ソースコード

diff #

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

vector<pair<char, int>> rlencoding(string vec) {
  vector<pair<char, int>> res = {{vec[0], 1}};
  int n = (int)vec.size();
  for (int i = 1; i < n; i++) {
    if (vec[i] == res.back().first) res.back().second++;
    else res.push_back({vec[i], 1});
  }
  return res;
}

int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  vector vec = rlencoding(s);
  int ans = 0;
  for (auto [x, y]: vec) {
    if (x == '0' && y >= 2) ans += y/2;
  }
  cout << ans << endl;
}
0