結果

問題 No.1 道のショートカット
ユーザー monakamonaka
提出日時 2022-02-01 18:24:07
言語 TypeScript
(5.4.3)
結果
TLE  
実行時間 -
コード長 1,118 bytes
コンパイル時間 9,658 ms
コンパイル使用メモリ 252,996 KB
実行使用メモリ 50,644 KB
最終ジャッジ日時 2023-09-02 02:32:33
合計ジャッジ時間 17,905 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
42,204 KB
testcase_01 AC 75 ms
42,340 KB
testcase_02 AC 76 ms
42,188 KB
testcase_03 AC 74 ms
42,268 KB
testcase_04 AC 75 ms
42,184 KB
testcase_05 AC 75 ms
42,416 KB
testcase_06 AC 72 ms
42,240 KB
testcase_07 AC 73 ms
42,412 KB
testcase_08 AC 442 ms
48,420 KB
testcase_09 AC 103 ms
43,980 KB
testcase_10 AC 524 ms
50,644 KB
testcase_11 TLE -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
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 #

function main(line) {
  const n = Number(line.shift());
  const c = Number(line.shift());
  const v = Number(line.shift());
  const s = line.shift().split(" ").map(x=>Number(x)-1);
  const t = line.shift().split(" ").map(x=>Number(x)-1);
  const y = line.shift().split(" ").map(x=>Number(x));
  const m = line.shift().split(" ").map(x=>Number(x));
  const arr = [];
  for(let i=0; i<v; i++) {
    arr.push({s:s[i], t:t[i], y:y[i], m:m[i]});
  }
  const q = [{id:0, money:c, cost:0}];
  let minCost = Number.MAX_SAFE_INTEGER;
  while(q.length > 0) {
    const now = q.shift();
    const id = now.id;
    const money = now.money;
    const cost = now.cost;
    if(id === n-1) {
      if(cost < minCost) {
        minCost = cost;
      }
    }
    arr.filter(cur => cur.s === id).forEach(cur => {
      const nextMoney = money - cur.y;
      if(nextMoney >= 0) {
        const nextCost = cost + cur.m;
        q.push({id:cur.t, money:nextMoney, cost:nextCost});
      }
    });
  }
  console.log(minCost === Number.MAX_SAFE_INTEGER ? -1 : minCost);
}

main(require("fs").readFileSync("/dev/stdin", "utf8").split("\n"));
0