Skip to content

Commit

Permalink
pastbook2 abc229_d
Browse files Browse the repository at this point in the history
  • Loading branch information
bouzuya committed Jul 17, 2023
1 parent d229dde commit 5ddb99c
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 0 deletions.
6 changes: 6 additions & 0 deletions cargo-compete/pastbook2/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ edition = "2018"
171 = { alias = "arc084_a", problem = "https://atcoder.jp/contests/abc077/tasks/arc084_a" }
174 = { alias = "past202109_m", problem = "https://atcoder.jp/contests/past202109-open/tasks/past202109_m" }
179 = { alias = "abc032_c", problem = "https://atcoder.jp/contests/abc032/tasks/abc032_c" }
184 = { alias = "abc229_d", problem = "https://atcoder.jp/contests/abc229/tasks/abc229_d" }
# xxx = { alias = "", problem = "" }


[[bin]]
Expand Down Expand Up @@ -162,6 +164,10 @@ path = "src/bin/174.rs"
name = "179"
path = "src/bin/179.rs"

[[bin]]
name = "184"
path = "src/bin/184.rs"

[dependencies]
num = "=0.2.1"
num-bigint = "=0.2.6"
Expand Down
1 change: 1 addition & 0 deletions cargo-compete/pastbook2/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,4 @@
- P.171 Snuke Festival (AtCoder Beginner Contest 077:C問題) <https://atcoder.jp/contests/abc077/tasks/arc084_a>
- P.174 バランス (第八回 アルゴリズム実技検定:M問題) <https://atcoder.jp/contests/past202109-open/tasks/past202109_m>
- P.179 列 (AtCoder Beginner Contest 032:C問題) <https://atcoder.jp/contests/abc032/tasks/abc032_c>
- P.184 Longest X (AtCoder Beginner Contest 229:D問題) <https://atcoder.jp/contests/abc229/tasks/abc229_d>
28 changes: 28 additions & 0 deletions cargo-compete/pastbook2/src/bin/184.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
use proconio::{input, marker::Chars};

fn main() {
input! {
s: Chars,
k: usize,
};
let n = s.len();
let mut max = 0_usize;
let mut count = 0_usize;
let mut r = 0_usize;
for l in 0..n {
while (r < n) && ((s[r] == 'X') || (s[r] == '.' && count < k)) {
count += if s[r] == '.' { 1 } else { 0 };
r += 1;
}
max = max.max(r - l);
if r == l {
r += 1;
} else {
if s[l] == '.' {
count -= 1;
}
}
}
let ans = max;
println!("{}", ans);
}

0 comments on commit 5ddb99c

Please sign in to comment.