結果

問題 No.3015 右に寄せろ!
ユーザー hamikan
提出日時 2025-09-05 22:31:56
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 15 ms / 2,000 ms
コード長 424 bytes
コンパイル時間 1,892 ms
コンパイル使用メモリ 194,748 KB
実行使用メモリ 7,716 KB
最終ジャッジ日時 2025-09-05 22:32:33
合計ジャッジ時間 3,420 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 36
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    string S;
    cin >> S;
    S += '1';
    reverse(S.begin(), S.end());
    long long cnt = 0, ans = 0;
    for(int i=1; i<S.length(); i++) {
        if(S[i-1] == '1' && S[i] == '1') {
            S[i] = 'x';
            ans += cnt;
        }
        cnt += (S[i] == '0');
    }
    cout << ans << endl;
}
0