結果

問題 No.1 道のショートカット
ユーザー Kiri8128Kiri8128
提出日時 2020-09-05 18:13:38
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 161 ms / 5,000 ms
コード長 963 bytes
コンパイル時間 241 ms
コンパイル使用メモリ 87,004 KB
実行使用メモリ 88,236 KB
最終ジャッジ日時 2023-09-27 22:32:40
合計ジャッジ時間 5,835 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 69 ms
71,376 KB
testcase_01 AC 69 ms
71,448 KB
testcase_02 AC 70 ms
71,312 KB
testcase_03 AC 70 ms
71,156 KB
testcase_04 AC 69 ms
71,156 KB
testcase_05 AC 70 ms
71,416 KB
testcase_06 AC 68 ms
71,312 KB
testcase_07 AC 69 ms
71,468 KB
testcase_08 AC 149 ms
86,524 KB
testcase_09 AC 96 ms
81,368 KB
testcase_10 AC 120 ms
79,768 KB
testcase_11 AC 122 ms
80,948 KB
testcase_12 AC 161 ms
88,236 KB
testcase_13 AC 155 ms
87,952 KB
testcase_14 AC 73 ms
76,220 KB
testcase_15 AC 69 ms
75,124 KB
testcase_16 AC 76 ms
76,620 KB
testcase_17 AC 69 ms
75,172 KB
testcase_18 AC 76 ms
76,112 KB
testcase_19 AC 76 ms
76,164 KB
testcase_20 AC 107 ms
79,284 KB
testcase_21 AC 89 ms
76,420 KB
testcase_22 AC 79 ms
76,096 KB
testcase_23 AC 132 ms
85,300 KB
testcase_24 AC 143 ms
87,124 KB
testcase_25 AC 112 ms
80,892 KB
testcase_26 AC 109 ms
79,392 KB
testcase_27 AC 134 ms
84,924 KB
testcase_28 AC 76 ms
76,084 KB
testcase_29 AC 102 ms
79,032 KB
testcase_30 AC 79 ms
76,524 KB
testcase_31 AC 85 ms
76,776 KB
testcase_32 AC 122 ms
83,336 KB
testcase_33 AC 107 ms
81,448 KB
testcase_34 AC 123 ms
82,096 KB
testcase_35 AC 75 ms
76,308 KB
testcase_36 AC 93 ms
76,812 KB
testcase_37 AC 81 ms
76,804 KB
testcase_38 AC 78 ms
76,240 KB
testcase_39 AC 79 ms
76,232 KB
testcase_40 AC 80 ms
76,656 KB
testcase_41 AC 74 ms
76,156 KB
testcase_42 AC 74 ms
71,304 KB
testcase_43 AC 71 ms
75,180 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from heapq import heapify, heappush as hpush, heappop as hpop

N, C, V = int(input()), int(input()), int(input())
S = [int(a)-1 for a in input().split()]
T = [int(a)-1 for a in input().split()]
Y = [int(a) for a in input().split()]
M = [int(a) for a in input().split()]

X = [[] for _ in range(N * (C + 1))]
# i * N + j: i 円使って頂点jにいる状態
for s, t, y, m in zip(S, T, Y, M):
    for i in range(y, C + 1):
        X[(i-y)*N+s].append((i*N+t, m))

def dijkstra(n, E, i0=0):
    kk = 18
    mm = (1 << kk) - 1
    h = [i0]
    D = [1 << 30] * n
    done = [0] * n
    D[i0] = 0
    
    while h:
        x = hpop(h)
        d, i = x >> kk, x & mm
        done[i] = 1
        for j, w in E[i]:
            nd = d + w
            if D[j] < 0 or D[j] > nd:
                if done[j] == 0:
                    hpush(h, (nd << kk) + j)
                    D[j] = nd
    return (min(D[N-1::N]) + 1) % (2 ** 30 + 1) - 1

print(dijkstra(N * (C + 1), X))

0