結果

問題 No.3015 右に寄せろ!
ユーザー mihhiael
提出日時 2025-01-25 13:32:18
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 15 ms / 2,000 ms
コード長 939 bytes
コンパイル時間 1,433 ms
コンパイル使用メモリ 130,004 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2025-01-25 22:50:35
合計ジャッジ時間 2,838 ms
ジャッジサーバーID
(参考情報)
judge11 / judge8
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 36
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdint>
#include <numeric>
#include <set>
#include <unordered_set>
#include <map>
#include <vector>
#include <string>
#include <deque>
#include <queue>
#include <iomanip>

using namespace std;
using ll  = long long;
using pall = pair<ll,ll>;
using vell = vector<ll>;

template<class T, class U>
constexpr bool mini(T &var, const U &val) noexcept {
	const bool cmp = var > val;
	if(cmp) var = val;
	return cmp;
}
template<class T, class U>
constexpr bool maxi(T &var, const U &val) noexcept {
	const bool cmp = var < val;
	if(cmp) var = val;
	return cmp;
}

void solve();

int main(void) {
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	solve();
	return 0;
}

void solve() {
	string s;
	cin >> s;
	ll leftz = 0;
	ll ans = 0;
	for(const auto &e:s) {
		if(e == '1') leftz++;
		else {
			ans += leftz / 2;
			leftz -= leftz % 2;
		}
	}
	cout << ans;
}
0