Skip to content

Commit

Permalink
Add atcoder/abc376/a.rs atcoder/abc376/remain.txt
Browse files Browse the repository at this point in the history
  • Loading branch information
koba-e964 committed Nov 7, 2024
1 parent 96ce161 commit 2a731fb
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
39 changes: 39 additions & 0 deletions atcoder/abc376/a.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
use std::io::Read;

fn get_word() -> String {
let stdin = std::io::stdin();
let mut stdin=stdin.lock();
let mut u8b: [u8; 1] = [0];
loop {
let mut buf: Vec<u8> = Vec::with_capacity(16);
loop {
let res = stdin.read(&mut u8b);
if res.unwrap_or(0) == 0 || u8b[0] <= b' ' {
break;
} else {
buf.push(u8b[0]);
}
}
if buf.len() >= 1 {
let ret = String::from_utf8(buf).unwrap();
return ret;
}
}
}

fn get<T: std::str::FromStr>() -> T { get_word().parse().ok().unwrap() }

fn main() {
let n: usize = get();
let c: i32 = get();
let t: Vec<i32> = (0..n).map(|_| get()).collect();
let mut ans = 1;
let mut last = t[0];
for i in 1..n {
if t[i] - last >= c {
ans += 1;
last = t[i];
}
}
println!("{}", ans);
}
6 changes: 6 additions & 0 deletions atcoder/abc376/remain.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
b
c
d
e
f
g

0 comments on commit 2a731fb

Please sign in to comment.