Skip to content

Commit

Permalink
tessoku-book a35
Browse files Browse the repository at this point in the history
  • Loading branch information
bouzuya committed Oct 21, 2022
1 parent fea1811 commit 6ff6d47
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions tessoku-book/src/bin/a35.rs
@@ -1,10 +1,22 @@
use proconio::{input, marker::Usize1};
use proconio::input;

fn main() {
input! {
n: usize,
a: [Usize1; n],
a: [usize; n],
};
let ans = n - a.len();

let mut dp = a;
for i in (1..n).rev() {
let mut parent = vec![0; dp.len() - 1];
for j in 0..parent.len() {
let l = dp[j];
let r = dp[j + 1];
parent[j] = if i % 2 == 0 { l.min(r) } else { l.max(r) };
}
dp = parent;
}

let ans = dp[0];
println!("{}", ans);
}

0 comments on commit 6ff6d47

Please sign in to comment.