結果
| 問題 |
No.1 道のショートカット
|
| コンテスト | |
| ユーザー |
rlangevin
|
| 提出日時 | 2023-11-17 19:44:23 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 68 ms / 5,000 ms |
| コード長 | 708 bytes |
| コンパイル時間 | 311 ms |
| コンパイル使用メモリ | 82,320 KB |
| 実行使用メモリ | 66,432 KB |
| 最終ジャッジ日時 | 2024-09-26 05:32:19 |
| 合計ジャッジ時間 | 4,102 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 40 |
ソースコード
import sys
input = sys.stdin.readline
N = int(input())
C = int(input())
V = int(input())
S = list(map(int, input().split()))
T = list(map(int, input().split()))
Y = list(map(int, input().split()))
M = list(map(int, input().split()))
G = [[] for i in range(N)]
for s, t, y, m in zip(S, T, Y, M):
G[s - 1].append((t - 1, y, m))
inf = 10 ** 18
dp = [[inf] * (C + 1) for _ in range(N)]
dp[0][0] = 0
for i in range(N):
for c in range(C):
if dp[i][c] == inf:
continue
for u, y, m in G[i]:
if c + y > C:
continue
dp[u][c + y] = min(dp[u][c + y], dp[i][c] + m)
ans = min(dp[N - 1])
print(ans) if ans != inf else print(-1)
rlangevin