結果
| 問題 |
No.1 道のショートカット
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-04-27 23:21:12 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,044 bytes |
| コンパイル時間 | 174 ms |
| コンパイル使用メモリ | 12,672 KB |
| 実行使用メモリ | 10,880 KB |
| 最終ジャッジ日時 | 2024-07-08 05:22:19 |
| 合計ジャッジ時間 | 11,690 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 7 TLE * 1 -- * 32 |
ソースコード
class heap_queue:
def __init__(self):
self.queue = [(0, 0, 0)] # 時間, 駅, コスト
def add(self, *item):
self.queue.append(tuple(item))
self.queue.sort(key=lambda x:x[0], reverse=True)
def dequeue(self):
if not self.size():
return False
return self.queue.pop()
def size(self):
return len(self.queue)
N = int(input())
C = int(input())
V = int(input())
S = list(map(lambda x:int(x) - 1, input().split())) # 行く前
T = list(map(lambda x:int(x) - 1, input().split())) # 行った後
Y = list(map(int, input().split())) # コスト
M = list(map(int, input().split())) # 時間
dp = [10 ** 9 for j in range(N)]
dp[0] = 0
heap = heap_queue()
while heap.size():
data = list(heap.dequeue())
for i in range(V):
if S[i] == data[1]:
if Y[i] + data[2] <= C:
dp[T[i]] = min(dp[T[i]], data[0] + M[i])
heap.add(dp[T[i]], T[i], Y[i] + data[2])
print(dp[N - 1] if dp[N - 1] != 10 ** 9 else -1)