結果
問題 |
No.3015 右に寄せろ!
|
ユーザー |
|
提出日時 | 2025-01-25 18:55:32 |
言語 | Rust (1.83.0 + proconio) |
結果 |
AC
|
実行時間 | 45 ms / 2,000 ms |
コード長 | 1,027 bytes |
コンパイル時間 | 13,329 ms |
コンパイル使用メモリ | 378,416 KB |
実行使用メモリ | 43,008 KB |
最終ジャッジ日時 | 2025-01-26 00:01:38 |
合計ジャッジ時間 | 15,571 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 36 |
ソースコード
#[allow(unused_imports)] use std::{ collections::*, cmp::*, mem::swap, time::Instant, io::{self, stdin, Read, read_to_string}, hash::Hash, }; #[allow(unused_imports)] use proconio::{input, input_interactive, marker::{*}}; #[allow(unused_imports)] //use rand::{thread_rng, Rng, seq::SliceRandom}; #[allow(unused_imports)] //use ac_library::{*}; #[allow(dead_code)] const INF: i64 = 1<<61; #[allow(dead_code)] const MOD: i64 = 998244353; #[allow(dead_code)] const D: [(usize, usize); 4] = [(1, 0), (0, 1), (!0, 0), (0, !0)]; //use proconio::fastout; //#[fastout] fn main(){ input!{ s: Chars, } let mut t = Vec::new(); let mut z = 0; for &c in &s{ t.push((c, 1)); } t.dedup_by(|u, v| if u.0==v.0{ *v = (u.0, u.1+v.1); true } else { false }); let mut ans = 0i64; for &(c, v) in t.iter().rev(){ if c=='1'{ ans += z*(v/2); } else { z += v; } } println!("{}", ans); }