結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 24 ms
9,068 KB
testcase_01 AC 23 ms
9,280 KB
testcase_02 AC 24 ms
9,100 KB
testcase_03 AC 24 ms
9,236 KB
testcase_04 AC 23 ms
9,272 KB
testcase_05 AC 23 ms
9,116 KB
testcase_06 AC 23 ms
9,248 KB
testcase_07 AC 24 ms
9,120 KB
testcase_08 TLE -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
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()]

global sum
sum=math.inf
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(node,cost,minute):
    if node.index==n-1:
        global sum
        if minute<sum and cost<=c:
            sum=minute
        return
    for to in range(len(node.edges_to)):
        fun(nodes[node.edges_to[to]],cost+node.edges_cost[to],node.edges_minute[to]+minute)

    return

fun(nodes[0],0,0)
print(-1 if sum==math.inf else sum)
0