ABC 048, finished all with help of editorial
This commit is contained in:
25
atcoder/beginner_contests/abc048/Cargo.lock
generated
Normal file
25
atcoder/beginner_contests/abc048/Cargo.lock
generated
Normal file
@@ -0,0 +1,25 @@
|
||||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
version = 3
|
||||
|
||||
[[package]]
|
||||
name = "abc048"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"proconio",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "lazy_static"
|
||||
version = "1.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
|
||||
|
||||
[[package]]
|
||||
name = "proconio"
|
||||
version = "0.4.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "91c333be3af2936f8e810300bc74fe4d0cc168ebc04ab02a28c5b1060fa1bd59"
|
||||
dependencies = [
|
||||
"lazy_static",
|
||||
]
|
||||
12
atcoder/beginner_contests/abc048/Cargo.toml
Normal file
12
atcoder/beginner_contests/abc048/Cargo.toml
Normal file
@@ -0,0 +1,12 @@
|
||||
[package]
|
||||
name = "abc048"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
# dependencies added to new project
|
||||
[dependencies]
|
||||
proconio = "0.4.3"
|
||||
|
||||
[profile.release]
|
||||
lto = true
|
||||
panic = 'abort'
|
||||
11
atcoder/beginner_contests/abc048/src/bin/a.rs
Normal file
11
atcoder/beginner_contests/abc048/src/bin/a.rs
Normal file
@@ -0,0 +1,11 @@
|
||||
use proconio::input;
|
||||
|
||||
fn main(){
|
||||
input!{
|
||||
_atcoder: String,
|
||||
s: String,
|
||||
_contest: String,
|
||||
};
|
||||
|
||||
println!("A{}C", s.chars().next().unwrap());
|
||||
}
|
||||
21
atcoder/beginner_contests/abc048/src/bin/b.rs
Normal file
21
atcoder/beginner_contests/abc048/src/bin/b.rs
Normal file
@@ -0,0 +1,21 @@
|
||||
use proconio::input;
|
||||
|
||||
fn f(n: i64, x: i64) -> i64 {
|
||||
if n == -1 {
|
||||
0
|
||||
} else {
|
||||
n / x + 1
|
||||
}
|
||||
}
|
||||
|
||||
fn main(){
|
||||
input!{
|
||||
a: i64,
|
||||
b: i64,
|
||||
x: i64,
|
||||
};
|
||||
|
||||
let result = f(b, x) - f(a - 1, x);
|
||||
|
||||
println!("{}", result);
|
||||
}
|
||||
25
atcoder/beginner_contests/abc048/src/bin/c.rs
Normal file
25
atcoder/beginner_contests/abc048/src/bin/c.rs
Normal file
@@ -0,0 +1,25 @@
|
||||
use proconio::input;
|
||||
|
||||
fn main(){
|
||||
input!{
|
||||
n: u64,
|
||||
x: u64,
|
||||
mut a: [u64; n],
|
||||
};
|
||||
|
||||
let mut result = 0;
|
||||
for i in 0..=((n-2) as usize) {
|
||||
if a[i] + a[i+1] > x {
|
||||
let dif = a[i] + a[i+1] - x;
|
||||
if dif > a[i+1] {
|
||||
a[i] -= dif - a[i+1];
|
||||
a[i+1] = 0;
|
||||
} else {
|
||||
a[i+1] -= dif;
|
||||
}
|
||||
result += dif;
|
||||
}
|
||||
}
|
||||
|
||||
println!("{}", result);
|
||||
}
|
||||
13
atcoder/beginner_contests/abc048/src/bin/d.rs
Normal file
13
atcoder/beginner_contests/abc048/src/bin/d.rs
Normal file
@@ -0,0 +1,13 @@
|
||||
use proconio::input;
|
||||
|
||||
fn main(){
|
||||
input!{
|
||||
s: String,
|
||||
};
|
||||
|
||||
if (s.len() % 2 == 0) ^ (s.chars().next().unwrap() == s.chars().last().unwrap()) {
|
||||
println!("Second");
|
||||
} else {
|
||||
println!("First");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user