結果
| 問題 | No.1 道のショートカット |
| コンテスト | |
| ユーザー |
👑 |
| 提出日時 | 2022-01-20 12:11:19 |
| 言語 | PyPy3 (8.0.0 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 402 ms / 5,000 ms |
| + 537µs | |
| コード長 | 796 bytes |
| 記録 | |
| コンパイル時間 | 85 ms |
| コンパイル使用メモリ | 65,208 KB |
| 実行使用メモリ | 84,668 KB |
| 最終ジャッジ日時 | 2026-10-13 12:03:45 |
| 合計ジャッジ時間 | 4,804 ms |
|
ジャッジサーバーID (参考情報) |
judge4_0 / judge5_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 42 |
ソースコード
import heapq
import sys
input = sys.stdin.readline
def main():
N = int(input())
C = int(input())
V = int(input())
*S, = map(int, input().split())
*T, = map(int, input().split())
*Y, = map(int, input().split())
*M, = map(int, input().split())
adj = [[] for i in range(N)]
for i in range(V):
adj[S[i]-1].append((T[i]-1, Y[i], M[i]))
vis = [[False]*N for i in range(C+1)]
Q = [(0, C, 0)]
while len(Q) != 0:
d, c, v = heapq.heappop(Q)
if vis[c][v]:
continue
vis[c][v] = True
if v == N-1:
print(d)
return
for u, nc, nd in adj[v]:
if c >= nc:
heapq.heappush(Q, (d+nd, c-nc, u))
print(-1)
if __name__ == '__main__':
main()