結果

問題 No.3015 右に寄せろ!
コンテスト
ユーザー anchuyu
提出日時 2026-01-02 13:55:54
言語 C++23
(gcc 15.2.0 + boost 1.89.0)
結果
WA  
実行時間 -
コード長 390 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 3,250 ms
コンパイル使用メモリ 333,776 KB
実行使用メモリ 9,044 KB
最終ジャッジ日時 2026-01-02 13:55:59
合計ジャッジ時間 5,441 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 11 WA * 25
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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

int main () {
  string s;
  cin >> s;
  
  int ans = 0;
  int one_count = 0;
  for(int i = 0; i < s.size(); i++){
    if(s[i] == '1'){
      if(one_count > 0){
        one_count++;
      } else if(i < s.size() - 1 && s[i + 1] == '1') {
        one_count++;
      }
    } else {
      ans += one_count / 2;
    }
  }
  
  cout << ans << endl;
}
0