結果
| 問題 |
No.1 道のショートカット
|
| コンテスト | |
| ユーザー |
n_knuu
|
| 提出日時 | 2015-05-07 17:58:34 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
AC
|
| 実行時間 | 283 ms / 5,000 ms |
| コード長 | 808 bytes |
| コンパイル時間 | 209 ms |
| コンパイル使用メモリ | 12,672 KB |
| 実行使用メモリ | 11,648 KB |
| 最終ジャッジ日時 | 2024-07-20 16:13:40 |
| 合計ジャッジ時間 | 4,769 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 40 |
ソースコード
from queue import PriorityQueue as PQueue
N = int(input())
C = int(input())
V = int(input())
S = list(map(lambda x: int(x)-1, input().split()))
T = list(map(lambda x: int(x)-1, input().split()))
Y = list(map(int, input().split()))
M = list(map(int, input().split()))
E = [[] for _ in range(N)]
for f, t, cost, time in zip(S, T, Y, M):
E[t].append((f, cost, time))
INF = 10**7
dp = [[INF] * (C+1) for _ in range(N)]
for i in range(C+1):
dp[0][i] = 0
while True:
flag = False
for t in range(N):
for j in range(C+1):
for f, cost, time in E[t]:
if j >= cost and dp[t][j] > dp[f][j-cost] + time:
dp[t][j] = dp[f][j-cost] + time
flag = True
if not flag:
break
print(min(dp[N-1]) if min(dp[N-1]) != INF else -1)
n_knuu