結果

問題 No.3015 右に寄せろ!
ユーザー sai
提出日時 2025-01-25 14:49:30
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 423 bytes
コンパイル時間 3,255 ms
コンパイル使用メモリ 275,076 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2025-01-25 23:30:44
合計ジャッジ時間 4,763 ms
ジャッジサーバーID
(参考情報)
judge6 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 6 WA * 30
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  std::string S; std::cin >> S;
  std::reverse(S.begin(), S.end());
  int ans = 0;
  int idx = -1;
  for (int i = 0; i + 2 < (int)S.size(); i++) {
    if (S.substr(i, 3) == "011") {
      ans += i - idx;
      idx += 2;
      i += 2;
    } else if (S[i] == '1') {
      idx = i + 1;
    }
  }
  std::cout << ans << '\n';
}
0