結果
| 問題 | No.1 道のショートカット |
| コンテスト | |
| ユーザー |
vjudge1
|
| 提出日時 | 2025-09-04 21:21:17 |
| 言語 | TypeScript (6.0.2) |
| 結果 |
CE
(最新)
WA
(最初)
|
| 実行時間 | - |
| コード長 | 1,407 bytes |
| 記録 | |
| コンパイル時間 | 1,111 ms |
| コンパイル使用メモリ | 193,408 KB |
| 最終ジャッジ日時 | 2026-07-14 14:06:47 |
| 合計ジャッジ時間 | 1,915 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge3_0 |
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
コンパイルメッセージ
main.ts(11,28): error TS2345: Argument of type 'number' is not assignable to parameter of type 'never'. main.ts(16,27): error TS2322: Type 'number' is not assignable to type 'never'. main.ts(17,27): error TS2322: Type 'number' is not assignable to type 'never'.
ソースコード
function main(): void {
const input = require('fs').readFileSync(0, 'utf-8').trim().split(/\s+/);
let index = 0;
const [N, C, V] = [input[index++], input[index++], input[index++]].map(Number);
// Read all arrays in one go
const arrays = [[], [], [], []];
for (let i = 0; i < 4; i++) {
for (let j = 0; j < V; j++) {
arrays[i].push(Number(input[index++]));
}
}
const [S, T, Y, M] = arrays;
S.forEach((val, i) => S[i] = val - 1); // Adjust S indices
T.forEach((val, i) => T[i] = val - 1); // Adjust T indices
// Build graph
const graph: Array<Array<[number, number, number]>> = Array(N).fill(0).map(() => []);
for (let i = 0; i < V; i++) {
graph[S[i]].push([T[i], Y[i], M[i]]);
}
// DP setup
const INF = 1e9;
const dp = Array(N).fill(0).map(() => Array(C + 1).fill(INF));
dp[0][C] = 0;
// Process DP
for (let i = 0; i < N; i++) {
for (let k = C; k >= 0; k--) {
if (dp[i][k] === INF) continue;
for (const [to, cost, time] of graph[i]) {
if (k >= cost) {
dp[to][k - cost] = Math.min(dp[to][k - cost], dp[i][k] + time);
}
}
}
}
// Output result
const result = Math.min(...dp[N - 1]);
console.log(result === INF ? -1 : result);
}
vjudge1