結果
| 問題 |
No.1 道のショートカット
|
| コンテスト | |
| ユーザー |
こる
|
| 提出日時 | 2017-01-03 14:14:52 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,111 bytes |
| コンパイル時間 | 92 ms |
| コンパイル使用メモリ | 12,544 KB |
| 実行使用メモリ | 16,640 KB |
| 最終ジャッジ日時 | 2024-07-08 04:36:32 |
| 合計ジャッジ時間 | 6,998 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 4 TLE * 1 -- * 35 |
ソースコード
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)
こる