ABC 048, finished all with help of editorial

This commit is contained in:
2022-06-10 12:29:12 +02:00
parent 6de228cf8a
commit 8ce2a3e769
6 changed files with 107 additions and 0 deletions

View File

@@ -0,0 +1,11 @@
use proconio::input;
fn main(){
input!{
_atcoder: String,
s: String,
_contest: String,
};
println!("A{}C", s.chars().next().unwrap());
}

View 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);
}

View 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);
}

View 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");
}
}