Skip to content

Commit

Permalink
arc135 b
Browse files Browse the repository at this point in the history
  • Loading branch information
bouzuya committed May 30, 2022
1 parent b686fe5 commit 463230f
Showing 1 changed file with 30 additions and 4 deletions.
34 changes: 30 additions & 4 deletions arc135/src/bin/b.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,36 @@
use proconio::{input, marker::Usize1};
use proconio::input;

fn main() {
input! {
n: usize,
a: [Usize1; n],
s: [i64; n],
};
let ans = n - a.len();
println!("{}", ans);
let mut p = (0, 0);
let mut c = (0, 0, s[0]);
for (i, s_i) in s.iter().copied().enumerate() {
let p2 = s_i - (p.0 + p.1);
p.0 = p.1;
p.1 = p2;
match (i + 2) % 3 {
0 => c.0 = c.0.min(p2),
1 => c.1 = c.1.min(p2),
2 => c.2 = c.2.min(p2),
_ => unreachable!(),
}
}
let ans = -c.0 + -c.1 <= c.2;
println!("{}", if ans { "Yes" } else { "No" });
if ans {
let c0 = -c.0;
let c1 = -c.1;
println!("{}", c0);
println!("{}", c1);
let mut p = (c0, c1);
for s_i in s {
let p2 = s_i - (p.0 + p.1);
println!("{}", p2);
p.0 = p.1;
p.1 = p2;
}
}
}

0 comments on commit 463230f

Please sign in to comment.