-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
30 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} | ||
} |