結果

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
vector<pair<char, int>> runLength(const string &vec) {
	vector<pair<char, int>> res;
	for (const auto &p : vec) {
		if (res.size() == 0 || res.back().first != p) {
			res.push_back({p, 1});
		} else {
			res.back().second++;
		}
	}
	return res;
};
int main() {
	int n;
	cin >> n;
	string s;
	cin >> s;
	auto f = runLength(s);
	int ans = 0;
	for (auto [c, cnt] : f) {
		if (c == '0') {
			ans += cnt - 1;
		}
	}
	cout << ans << endl;
	return 0;
}
0