結果

問題 No.3015 右に寄せろ!
コンテスト
ユーザー 麻崎 系
提出日時 2026-11-14 08:42:08
言語 C++23(gcc16)
(gcc 16.2.0 + boost 1.92.0 + ACL)
コンパイル:
g++-16 -O2 -fplugin=/usr/lib/yukicoder/noavx512-gcc16.so -lm -std=c++23 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
実行時間 -
コード長 610 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 3,036 ms
コンパイル使用メモリ 353,400 KB
実行使用メモリ 9,924 KB
最終ジャッジ日時 2026-11-14 08:42:16
合計ジャッジ時間 6,197 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 8 WA * 28
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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

int main() {
    string S;
    cin >> S;

    int n = S.size();
    
    int most_right_zero = 0;
    for (int i = n - 1; i >= 0; i--) {
        if (S.at(i) == '0') {
            most_right_zero = i;
            break;
        }
    }

    int ans = 0;
    bool plus = true;
    for (int i = 0; i < n - 2; i++) {
        if (S.at(i) == '1' && S.at(i+1) == '1' && S.at(i+2) == '0') {
            if (plus) {ans += most_right_zero - (i + 1);}
            else {ans -= most_right_zero - (i + 1);}
            plus = !plus;
        }
    }

    cout << ans << endl;
}
0