結果
| 問題 |
No.1 道のショートカット
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-04-24 10:59:05 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 52 ms / 5,000 ms |
| コード長 | 741 bytes |
| コンパイル時間 | 204 ms |
| コンパイル使用メモリ | 82,256 KB |
| 実行使用メモリ | 67,792 KB |
| 最終ジャッジ日時 | 2024-07-04 09:03:26 |
| 合計ジャッジ時間 | 3,103 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 40 |
ソースコード
import sys
sys.setrecursionlimit(10**7)
def dfs(s,y,m):
global ans
global cost_time
if s == N-1 and y <= C:
ans = min(ans,m)
for to, cost, time in adj[s]:
if y + cost <= C and m < ans:
dfs(to,y+cost,m+time)
# 入力の受け取り・隣接リストadjの構築:
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()))
adj = [[] for _ in range(N)]
for i in range(V):
adj[S[i]-1].append((T[i]-1, Y[i], M[i]))
ans = float("INF")
cost_time = []
dfs(0,0,0)
ans = -1 if ans == float("INF") else ans
print(ans)