From 132ea01eb26a8d703b3ac2ffe165045a15f8a589 Mon Sep 17 00:00:00 2001 From: koba-e964 <3303362+koba-e964@users.noreply.github.com> Date: Sat, 9 Nov 2024 15:04:41 +0900 Subject: [PATCH] Add atcoder/abc365/a.rs atcoder/abc365/b.rs atcoder/abc365/c.rs atcoder/abc365/remain.txt --- atcoder/abc365/a.rs | 10 ++++++++ atcoder/abc365/b.rs | 40 +++++++++++++++++++++++++++++ atcoder/abc365/c.rs | 53 +++++++++++++++++++++++++++++++++++++++ atcoder/abc365/remain.txt | 4 +++ 4 files changed, 107 insertions(+) create mode 100644 atcoder/abc365/a.rs create mode 100644 atcoder/abc365/b.rs create mode 100644 atcoder/abc365/c.rs create mode 100644 atcoder/abc365/remain.txt diff --git a/atcoder/abc365/a.rs b/atcoder/abc365/a.rs new file mode 100644 index 00000000..1ff44e23 --- /dev/null +++ b/atcoder/abc365/a.rs @@ -0,0 +1,10 @@ +fn getline() -> String { + let mut ret = String::new(); + std::io::stdin().read_line(&mut ret).ok().unwrap(); + ret +} + +fn main() { + let y = getline().trim().parse::().unwrap(); + println!("{}", 365 + ((y % 400 == 0) ^ (y % 100 == 0) ^ (y % 4 == 0)) as i32); +} diff --git a/atcoder/abc365/b.rs b/atcoder/abc365/b.rs new file mode 100644 index 00000000..7a26723a --- /dev/null +++ b/atcoder/abc365/b.rs @@ -0,0 +1,40 @@ +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 mut a: Vec = vec![0; n]; + for i in 0..n { + a[i] = get(); + } + let mut b = a.clone(); + b.sort(); + for i in 0..n { + if a[i] == b[n - 2] { + println!("{}", i + 1); + return; + } + } +} diff --git a/atcoder/abc365/c.rs b/atcoder/abc365/c.rs new file mode 100644 index 00000000..46705a45 --- /dev/null +++ b/atcoder/abc365/c.rs @@ -0,0 +1,53 @@ +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 m: i64 = get(); + let mut a: Vec = vec![0; n]; + for i in 0..n { + a[i] = get(); + } + let asum = a.iter().sum::(); + if asum <= m { + println!("infinite"); + return; + } + let mut pass = 0; + let mut fail = 1 << 30; + while fail - pass > 1 { + let mid = (pass + fail) / 2; + let mut sum = 0; + for i in 0..n { + sum += a[i].min(mid); + } + if sum <= m { + pass = mid; + } else { + fail = mid; + } + } + println!("{pass}"); +} diff --git a/atcoder/abc365/remain.txt b/atcoder/abc365/remain.txt new file mode 100644 index 00000000..9fcb84e1 --- /dev/null +++ b/atcoder/abc365/remain.txt @@ -0,0 +1,4 @@ +d +e +f +g