結果

問題 No.3015 右に寄せろ!
ユーザー ngtkana
提出日時 2024-11-16 03:22:50
言語 Rust
(1.83.0 + proconio)
結果
AC  
実行時間 16 ms / 2,000 ms
コード長 369 bytes
コンパイル時間 14,185 ms
コンパイル使用メモリ 378,492 KB
実行使用メモリ 5,888 KB
最終ジャッジ日時 2025-01-25 21:52:29
合計ジャッジ時間 16,348 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 36
権限があれば一括ダウンロードができます

ソースコード

diff #

use proconio::input;
use proconio::marker::Bytes;

fn main() {
    input! {
        s: Bytes,
    }
    let mut start = 0;
    let mut ans = 0_usize;
    for (i, &c) in s.iter().enumerate() {
        if c == b'0' {
            let next = start + (start + i) % 2;
            ans += (i - next) / 2;
            start = next + 1;
        }
    }
    println!("{ans}");
}
0