結果

問題 No.1 道のショートカット
ユーザー こるこる
提出日時 2017-01-03 15:21:05
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 1,092 bytes
コンパイル時間 71 ms
コンパイル使用メモリ 10,872 KB
実行使用メモリ 9,492 KB
最終ジャッジ日時 2023-09-22 12:53:55
合計ジャッジ時間 7,329 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 23 ms
9,104 KB
testcase_01 AC 22 ms
9,184 KB
testcase_02 AC 22 ms
9,160 KB
testcase_03 AC 24 ms
9,260 KB
testcase_04 AC 24 ms
9,248 KB
testcase_05 AC 23 ms
9,084 KB
testcase_06 AC 23 ms
9,176 KB
testcase_07 AC 22 ms
9,180 KB
testcase_08 AC 51 ms
9,384 KB
testcase_09 AC 26 ms
9,476 KB
testcase_10 AC 90 ms
9,492 KB
testcase_11 TLE -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import math
import queue

class Node:
    def __init__(self):
        self.index=None
        self.cost=0
        self.minute=math.inf
        self.edges_to=[]
        self.edges_cost=[]
        self.edges_minute=[]
        self. done=False
    def __lt__(self,opr):
        return self.minute < opr.minute

n=int(input())
c=int(input())
v=int(input())
s=[int(i) for i in input().split()]
t=[int(i) for i in input().split()]
y=[int(i) for i in input().split()]
m=[int(i) for i in input().split()]

nodes=[Node() for i in range(n)]

for i in range(len(s)):
    nodes[s[i]-1].edges_to.append(t[i]-1)
    nodes[s[i]-1].edges_cost.append(y[i])
    nodes[s[i]-1].edges_minute.append(m[i])

nodes[0].minute=0

for i in range(n):
    nodes[i].index=i

def fun(index,cost):
    if cost<0:
        return math.inf

    if index==n-1:
        return 0

    mini=math.inf
    for to in range(len(nodes[index].edges_to)):
        mini=min(fun(nodes[index].edges_to[to],cost-nodes[index].edges_cost[to])+nodes[index].edges_minute[to],mini)
    return mini

sum=fun(0,c)
print(-1 if sum==math.inf else sum)
0