結果

問題 No.1 道のショートカット
ユーザー tabataba
提出日時 2024-07-31 15:56:07
言語 Rust
(1.77.0)
結果
TLE  
実行時間 -
コード長 1,394 bytes
コンパイル時間 14,628 ms
コンパイル使用メモリ 390,492 KB
実行使用メモリ 13,888 KB
最終ジャッジ日時 2024-07-31 15:56:32
合計ジャッジ時間 22,767 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,812 KB
testcase_01 AC 1 ms
6,944 KB
testcase_02 AC 1 ms
6,940 KB
testcase_03 AC 1 ms
6,940 KB
testcase_04 AC 1 ms
6,944 KB
testcase_05 AC 1 ms
6,944 KB
testcase_06 AC 1 ms
6,940 KB
testcase_07 AC 1 ms
6,944 KB
testcase_08 AC 9 ms
6,944 KB
testcase_09 AC 2 ms
6,944 KB
testcase_10 AC 17 ms
6,944 KB
testcase_11 AC 1,148 ms
7,680 KB
testcase_12 AC 751 ms
10,368 KB
testcase_13 AC 283 ms
6,944 KB
testcase_14 AC 1 ms
6,940 KB
testcase_15 AC 1 ms
6,944 KB
testcase_16 AC 1 ms
6,944 KB
testcase_17 AC 1 ms
6,944 KB
testcase_18 AC 1 ms
6,944 KB
testcase_19 AC 1 ms
6,940 KB
testcase_20 AC 8 ms
6,944 KB
testcase_21 AC 1 ms
6,940 KB
testcase_22 AC 1 ms
6,940 KB
testcase_23 TLE -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

use std::collections::BTreeSet;

fn main() {
    proconio::input! {
        n: u64,
        c: u64,
        v: u64,
        s: [u64; v],
        t: [u64; v],
        y: [u64; v],
        m: [u64; v],
    }

    let goal = n - 1;
    let s = s.into_iter().map(|s| s - 1).collect::<Vec<_>>();
    let t = t.into_iter().map(|t| t - 1).collect::<Vec<_>>();
    let mut stym = s
        .into_iter()
        .zip(t.into_iter())
        .zip(y.into_iter())
        .zip(m.into_iter())
        .map(|(((s, t), y), m)| (s, t, y, m))
        .collect::<Vec<_>>();
    stym.sort_unstable();

    let mut moves = BTreeSet::new();
    moves.insert((0, 0, 0));
    let mut mtime_min = u64::MAX;
    loop {
        let mut new_moves = BTreeSet::new();
        moves.into_iter().for_each(|(town, cost, mtime)| {
            stym.iter()
                .filter(|(s, _, y, _)| *s == town && cost + y <= c)
                .for_each(|(_, t, y, m)| {
                    if *t == goal {
                        mtime_min = std::cmp::min(mtime_min, m + mtime);
                    } else {
                        new_moves.insert((*t, cost + y, mtime + m));
                    }
                });
        });
        moves = new_moves;
        if moves.is_empty() {
            break;
        }
    }
    if mtime_min == u64::MAX {
        println!("-1");
    } else {
        println!("{mtime_min}");
    }
}
0