結果

問題 No.1449 新プロランド
ユーザー hiragnhiragn
提出日時 2022-12-14 19:17:25
言語 PyPy3
(7.3.15)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 1,000 bytes
コンパイル時間 294 ms
コンパイル使用メモリ 87,088 KB
実行使用メモリ 80,116 KB
最終ジャッジ日時 2023-08-25 16:54:28
合計ジャッジ時間 6,133 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 102 ms
72,252 KB
testcase_01 AC 128 ms
78,204 KB
testcase_02 AC 149 ms
78,448 KB
testcase_03 AC 97 ms
71,576 KB
testcase_04 AC 120 ms
77,332 KB
testcase_05 AC 207 ms
79,340 KB
testcase_06 AC 190 ms
79,260 KB
testcase_07 AC 165 ms
79,136 KB
testcase_08 AC 185 ms
78,724 KB
testcase_09 AC 190 ms
78,912 KB
testcase_10 AC 178 ms
79,168 KB
testcase_11 AC 160 ms
79,040 KB
testcase_12 AC 164 ms
79,064 KB
testcase_13 AC 190 ms
78,940 KB
testcase_14 AC 125 ms
77,968 KB
testcase_15 AC 198 ms
79,448 KB
testcase_16 AC 169 ms
79,048 KB
testcase_17 AC 184 ms
78,824 KB
testcase_18 AC 92 ms
71,716 KB
testcase_19 AC 95 ms
71,704 KB
testcase_20 AC 94 ms
71,580 KB
testcase_21 AC 133 ms
78,412 KB
testcase_22 AC 133 ms
78,352 KB
testcase_23 AC 164 ms
78,820 KB
testcase_24 AC 176 ms
78,516 KB
testcase_25 WA -
testcase_26 AC 115 ms
77,548 KB
testcase_27 AC 217 ms
80,116 KB
testcase_28 AC 205 ms
79,908 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from heapq import heapify, heappop, heappush
from collections import defaultdict


def main():
    INF = 10 ** 18
    n, m = map(int, input().split())
    g = defaultdict(list)
    for _ in range(m):
        a, b, c = map(int, input().split())
        a -= 1
        b -= 1
        g[a].append([b, c])
        g[b].append([a, c])
    t = list(map(int, input().split()))

    # ダイクストラ
    dist = [[INF] * 501 for _ in range(n)]
    dist[0][0] = 0
    q = [(0, 0, 0)]  # (今の時間, 今いる頂点,おむすびを食べた時間)
    while q:
        cur_t, cur_v, eat_t = heappop(q)
        if dist[cur_v][eat_t] < cur_t:
            continue
        cur_t += t[cur_v]
        eat_t = min(eat_t + t[cur_v], 500)
        for v, cost in g[cur_v]:
            if dist[v][eat_t] > cur_t + cost // eat_t:
                dist[v][eat_t] = cur_t + cost // eat_t
                heappush(q, (cur_t + cost // eat_t, v, eat_t))
    print(min(dist[- 1]))


if __name__ == "__main__":
    main()
0