From 2a731fbb0c64f4ce5f3b053bc8e6809c1db03e1c Mon Sep 17 00:00:00 2001 From: koba-e964 <3303362+koba-e964@users.noreply.github.com> Date: Thu, 7 Nov 2024 22:57:19 +0900 Subject: [PATCH] Add atcoder/abc376/a.rs atcoder/abc376/remain.txt --- atcoder/abc376/a.rs | 39 +++++++++++++++++++++++++++++++++++++++ atcoder/abc376/remain.txt | 6 ++++++ 2 files changed, 45 insertions(+) create mode 100644 atcoder/abc376/a.rs create mode 100644 atcoder/abc376/remain.txt diff --git a/atcoder/abc376/a.rs b/atcoder/abc376/a.rs new file mode 100644 index 00000000..9b0e24a2 --- /dev/null +++ b/atcoder/abc376/a.rs @@ -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 = 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 { get_word().parse().ok().unwrap() } + +fn main() { + let n: usize = get(); + let c: i32 = get(); + let t: Vec = (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); +} diff --git a/atcoder/abc376/remain.txt b/atcoder/abc376/remain.txt new file mode 100644 index 00000000..9fbb6235 --- /dev/null +++ b/atcoder/abc376/remain.txt @@ -0,0 +1,6 @@ +b +c +d +e +f +g