2023-04-17 EDPC の A を解いた
- EDPC A - Frog 1 (AtCoder Educational DP Contest A問題) https://atcoder.jp/contests/dp/tasks/dp_a
use proconio::input;
macro_rules! chmin {
($min_v: expr, $v: expr) => {
if $v < $min_v {
$min_v = $v;
true
} else {
false
}
};
}
fn main() {
input! {
n: usize,
h: [i64; n],
}
let inf = 1_i64 << 60;
let mut dp = vec![inf; n];
dp[0] = 0_i64;
for i in 1..n {
for j in i.saturating_sub(2)..i {
chmin!(dp[i], dp[j] + (h[i] - h[j]).abs());
}
}
let ans = dp[n - 1];
println!("{}", ans);
}
今日のコミット。
- tsukota 1 commit
- rust-atcoder 1 commit