結果

問題 No.3015 右に寄せろ!
コンテスト
ユーザー ngtkana
提出日時 2024-11-16 02:17:25
言語 Rust
(1.94.0 + proconio + num + itertools)
コンパイル:
/usr/bin/rustc_custom
実行:
./target/release/main
結果
AC  
実行時間 12 ms / 2,000 ms
コード長 350 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 3,986 ms
コンパイル使用メモリ 188,928 KB
実行使用メモリ 6,400 KB
最終ジャッジ日時 2026-06-23 19:24:45
合計ジャッジ時間 3,427 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 36
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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