結果

問題 No.2095 High Rise
ユーザー phsplsphspls
提出日時 2022-10-16 13:34:24
言語 Rust
(1.77.0)
結果
AC  
実行時間 66 ms / 2,000 ms
コード長 1,045 bytes
コンパイル時間 4,340 ms
コンパイル使用メモリ 147,032 KB
実行使用メモリ 19,040 KB
最終ジャッジ日時 2023-09-09 16:50:55
合計ジャッジ時間 4,807 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,384 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 1 ms
4,380 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 1 ms
4,380 KB
testcase_15 AC 1 ms
4,380 KB
testcase_16 AC 1 ms
4,380 KB
testcase_17 AC 9 ms
4,380 KB
testcase_18 AC 6 ms
4,380 KB
testcase_19 AC 2 ms
4,380 KB
testcase_20 AC 10 ms
4,588 KB
testcase_21 AC 17 ms
5,984 KB
testcase_22 AC 66 ms
19,028 KB
testcase_23 AC 66 ms
18,952 KB
testcase_24 AC 66 ms
19,040 KB
testcase_25 AC 66 ms
19,032 KB
testcase_26 AC 66 ms
18,972 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

const INF: usize = 1usize << 60;

fn main() {
    let mut nm = String::new();
    std::io::stdin().read_line(&mut nm).ok();
    let nm: Vec<usize> = nm.trim().split_whitespace().map(|s| s.parse().unwrap()).collect();
    let n = nm[0];
    let m = nm[1];
    let mut rooms = (0..n).map(|_| {
            let mut temp = String::new();
            std::io::stdin().read_line(&mut temp).ok();
            let temp: Vec<usize> = temp.trim().split_whitespace().map(|s| s.parse().unwrap()).collect();
            temp
        })
        .collect::<Vec<_>>();

    if n == 1 {
        println!("0");
        return;
    }
    let n = n+1;
    rooms.insert(0, vec![0; m]);
    let mut dp = vec![vec![INF; m]; n];
    for i in 0..m { dp[0][i] = 0; }
    for i in 1..n {
        let minval = *dp[i-1].iter().min().unwrap();
        for j in 0..m {
            dp[i][j] = dp[i][j].min(dp[i-1][j] + rooms[i][j]);
            dp[i][j] = dp[i][j].min(minval + rooms[i-1][j] + rooms[i][j]);
        }
    }
    println!("{}", dp[n-1].iter().min().unwrap());
}
0