結果
問題 | No.1 道のショートカット |
ユーザー |
|
提出日時 | 2020-05-21 19:36:22 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
TLE
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 810 bytes |
コンパイル時間 | 324 ms |
コンパイル使用メモリ | 12,800 KB |
実行使用メモリ | 11,136 KB |
最終ジャッジ日時 | 2024-07-08 05:26:12 |
合計ジャッジ時間 | 8,534 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 39 TLE * 1 |
ソースコード
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())) adjacent_list = [[] for i in range(n+1)] for i in range(v): adjacent_list[s[i]].append([t[i],y[i],m[i]]) ans = 10**9 memo = [[10**9,10**9] for i in range(n+1)] def dfs(node,cost,time): if node == n: global ans ans = min(ans, time) if memo[node][0] < cost and memo[node][1] < time: return if memo[node][0] > cost and memo[node][1] > time: memo[node] = [cost, time] for n_node, n_cost, n_time in adjacent_list[node]: if n_cost + cost <= c: dfs(n_node,n_cost + cost, time + n_time) dfs(1,0,0) if ans == 10**9: print(-1) else: print(ans)