提出 #49376715
ソースコード 拡げる
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,
l: usize,
x: [usize; n],
t: [usize; 3],
};
let l = l * 2;
let x = x.into_iter().map(|x| x * 2).collect::<Vec<usize>>();
let h = {
let mut y = vec![false; l + 8 + 1];
for x_i in x {
y[x_i] = true;
}
y
};
let (t1, t2, t3) = (t[0] / 2, t[1] / 2, t[2]);
let inf = 1_usize << 60;
let mut dp = vec![vec![inf; 2]; l + 8 + 1];
dp[0][0] = 0_usize;
for i in (0..l).step_by(2) {
chmin!(
dp[i + 2][0],
dp[i][0] + t1 * 2 + if h[i + 2] { t3 } else { 0 }
);
chmin!(
dp[i + 1 + 2 + 1][0],
dp[i][0] + t1 + t2 * 2 + t1 + if h[i + 1 + 2 + 1] { t3 } else { 0 }
);
chmin!(
dp[i + 1 + 6 + 1][0],
dp[i][0] + t1 + t2 * 6 + t1 + if h[i + 1 + 6 + 1] { t3 } else { 0 }
);
for j in 1..=6 {
chmin!(dp[i + 1 + j][1], dp[i][0] + t1 + t2 * j);
}
}
let ans = dp[l][0].min(dp[l][1]);
println!("{}", ans);
}
提出情報
| 提出日時 | |
|---|---|
| 問題 | H - ハードル走 |
| ユーザ | bouzuya |
| 言語 | Rust (rustc 1.70.0) |
| 得点 | 6 |
| コード長 | 1284 Byte |
| 結果 | AC |
| 実行時間 | 11 ms |
| メモリ | 13644 KiB |
ジャッジ結果
| セット名 | All | ||
|---|---|---|---|
| 得点 / 配点 | 6 / 6 | ||
| 結果 |
|
| セット名 | テストケース |
|---|---|
| All | 0.txt, 1.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, 2.txt, 20.txt, 21.txt, 22.txt, 23.txt, 24.txt, 25.txt, 26.txt, 27.txt, 28.txt, 29.txt, 3.txt, 4.txt, 5.txt, 6.txt, 7.txt, 8.txt, 9.txt, s1.txt, s2.txt, s3.txt |
| ケース名 | 結果 | 実行時間 | メモリ |
|---|---|---|---|
| 0.txt | AC | 7 ms | 8940 KiB |
| 1.txt | AC | 5 ms | 7152 KiB |
| 10.txt | AC | 10 ms | 13308 KiB |
| 11.txt | AC | 9 ms | 13300 KiB |
| 12.txt | AC | 9 ms | 13296 KiB |
| 13.txt | AC | 9 ms | 13364 KiB |
| 14.txt | AC | 9 ms | 13332 KiB |
| 15.txt | AC | 9 ms | 13312 KiB |
| 16.txt | AC | 10 ms | 13256 KiB |
| 17.txt | AC | 9 ms | 13368 KiB |
| 18.txt | AC | 10 ms | 13232 KiB |
| 19.txt | AC | 9 ms | 13288 KiB |
| 2.txt | AC | 7 ms | 10304 KiB |
| 20.txt | AC | 11 ms | 13444 KiB |
| 21.txt | AC | 10 ms | 13504 KiB |
| 22.txt | AC | 10 ms | 13644 KiB |
| 23.txt | AC | 9 ms | 13292 KiB |
| 24.txt | AC | 9 ms | 13296 KiB |
| 25.txt | AC | 10 ms | 13164 KiB |
| 26.txt | AC | 9 ms | 13244 KiB |
| 27.txt | AC | 0 ms | 1948 KiB |
| 28.txt | AC | 1 ms | 1940 KiB |
| 29.txt | AC | 0 ms | 1848 KiB |
| 3.txt | AC | 1 ms | 2292 KiB |
| 4.txt | AC | 2 ms | 3548 KiB |
| 5.txt | AC | 3 ms | 4996 KiB |
| 6.txt | AC | 4 ms | 6376 KiB |
| 7.txt | AC | 2 ms | 4408 KiB |
| 8.txt | AC | 1 ms | 2364 KiB |
| 9.txt | AC | 1 ms | 2840 KiB |
| s1.txt | AC | 0 ms | 1956 KiB |
| s2.txt | AC | 0 ms | 2112 KiB |
| s3.txt | AC | 0 ms | 2104 KiB |