結果
| 問題 | No.3114 0→1 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-04-19 01:22:26 |
| 言語 | Rust (1.99.0 + proconio + num + itertools + ACL) |
| 結果 |
WJ
不安定
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 994 bytes |
| 記録 | |
| 最終ジャッジ日時 | 2026-10-16 03:22:55 |
|
ジャッジサーバーID (参考情報) |
judge5_0 / judge3_0 |
(要ログイン)
ソースコード
use proconio::{
fastout, input,
marker::{Chars, Usize1},
};
const DIRS: [(isize, isize); 4] = [(0, 1), (1, 0), (0, -1), (-1, 0)];
trait OrdExt {
fn chmax(&mut self, other: Self) -> bool;
fn chmin(&mut self, other: Self) -> bool;
}
impl<T: Ord> OrdExt for T {
fn chmax(&mut self, other: Self) -> bool {
if *self < other {
*self = other;
true
} else {
false
}
}
fn chmin(&mut self, other: Self) -> bool {
if *self > other {
*self = other;
true
} else {
false
}
}
}
#[fastout]
fn main() {
input! {
N: usize,
S: Chars
}
let mut ans = 0;
let mut tmp = if S[0] == '1' { 1 } else { -1 };
for i in 1..N {
if S[i] == '1' {
tmp += 1;
} else if tmp > 0 {
tmp = -1;
} else {
ans += 1;
tmp += 1;
}
}
println!("{}", ans);
}