結果

問題 No.1 道のショートカット
ユーザー ryusukeryusuke
提出日時 2022-01-28 20:03:24
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,265 bytes
コンパイル時間 316 ms
コンパイル使用メモリ 87,228 KB
実行使用メモリ 78,184 KB
最終ジャッジ日時 2023-08-28 17:29:36
合計ジャッジ時間 5,370 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
71,548 KB
testcase_01 AC 73 ms
71,276 KB
testcase_02 AC 73 ms
71,312 KB
testcase_03 AC 76 ms
71,496 KB
testcase_04 AC 73 ms
71,292 KB
testcase_05 AC 71 ms
71,140 KB
testcase_06 AC 70 ms
71,124 KB
testcase_07 AC 74 ms
71,292 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 72 ms
71,128 KB
testcase_16 WA -
testcase_17 AC 72 ms
71,440 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 72 ms
71,320 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 AC 75 ms
75,628 KB
testcase_36 WA -
testcase_37 WA -
testcase_38 AC 72 ms
71,636 KB
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 AC 71 ms
71,572 KB
testcase_43 AC 71 ms
71,512 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from heapq import heappush, heappop, heapify
import sys
input = sys.stdin.readline

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()))

g = [[] for _ in range(n)]

for i in range(v):
    s[i] -= 1
    t[i] -= 1
    g[s[i]].append((m[i], y[i], t[i])) # 時間・コスト・行き先
#print('g:のグラフ')
#print(*g, sep='\n')

INF = 10 ** 18
dist = [INF] * n # かかる時間
cost = [INF] * n # 必要なコスト
dist[0] = 0
cost[0] = 0
q = [(0, 0, 0)] # 時間・コスト・今いる場所
heapify(q)

while q:
    pre_time, pre_cost, pre_ind = heappop(q)
    for nxt_time, nxt_cost, nxt_ind in g[pre_ind]:
        if pre_cost != cost[pre_ind]:
            print('tigauo!',pre_cost, cost[pre_ind])
        if dist[nxt_ind] <= dist[pre_ind] + nxt_time: continue
        if pre_cost + nxt_cost > c: continue
        dist[nxt_ind] = dist[pre_ind] + nxt_time
        cost[nxt_ind] = pre_cost + nxt_cost
        heappush(q, (dist[nxt_ind], cost[nxt_ind], nxt_ind))
        #print(dist)
        #print(cost)
        #print(q)
        #print()

##print(dist)
#print(cost)
print(dist[-1]) if dist[-1] != INF else print(-1)
0