結果

問題 No.1 道のショートカット
ユーザー konchanksukonchanksu
提出日時 2020-04-27 23:21:12
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 1,044 bytes
コンパイル時間 100 ms
コンパイル使用メモリ 11,024 KB
実行使用メモリ 8,348 KB
最終ジャッジ日時 2023-09-22 13:42:01
合計ジャッジ時間 11,271 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
8,272 KB
testcase_01 AC 16 ms
8,268 KB
testcase_02 AC 15 ms
8,268 KB
testcase_03 AC 15 ms
8,348 KB
testcase_04 AC 15 ms
8,296 KB
testcase_05 AC 15 ms
8,148 KB
testcase_06 AC 15 ms
8,256 KB
testcase_07 AC 16 ms
8,272 KB
testcase_08 AC 1,264 ms
8,348 KB
testcase_09 AC 101 ms
8,240 KB
testcase_10 AC 2,725 ms
8,092 KB
testcase_11 TLE -
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 #

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