結果

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

ソースコード

diff #

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

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