結果

問題 No.1449 新プロランド
ユーザー tktk_snsntktk_snsn
提出日時 2023-02-09 23:27:39
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 398 ms / 2,000 ms
コード長 1,156 bytes
コンパイル時間 343 ms
コンパイル使用メモリ 87,180 KB
実行使用メモリ 82,824 KB
最終ジャッジ日時 2023-08-25 16:54:35
合計ジャッジ時間 7,250 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 91 ms
76,520 KB
testcase_01 AC 129 ms
77,972 KB
testcase_02 AC 161 ms
78,540 KB
testcase_03 AC 107 ms
77,548 KB
testcase_04 AC 136 ms
77,564 KB
testcase_05 AC 361 ms
82,156 KB
testcase_06 AC 284 ms
80,836 KB
testcase_07 AC 197 ms
79,460 KB
testcase_08 AC 303 ms
81,820 KB
testcase_09 AC 226 ms
79,112 KB
testcase_10 AC 214 ms
79,988 KB
testcase_11 AC 155 ms
79,344 KB
testcase_12 AC 283 ms
80,976 KB
testcase_13 AC 230 ms
78,908 KB
testcase_14 AC 145 ms
79,300 KB
testcase_15 AC 297 ms
80,936 KB
testcase_16 AC 234 ms
79,700 KB
testcase_17 AC 244 ms
80,128 KB
testcase_18 AC 74 ms
71,160 KB
testcase_19 AC 72 ms
71,328 KB
testcase_20 AC 80 ms
71,480 KB
testcase_21 AC 165 ms
79,424 KB
testcase_22 AC 145 ms
78,620 KB
testcase_23 AC 188 ms
79,852 KB
testcase_24 AC 203 ms
78,952 KB
testcase_25 AC 76 ms
71,328 KB
testcase_26 AC 110 ms
77,576 KB
testcase_27 AC 398 ms
82,824 KB
testcase_28 AC 278 ms
79,984 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import heapq
import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 7)
inf = 1 << 62


def main():
    N, M = map(int, input().split())
    G = [[] for _ in range(N + N)]
    for _ in range(M):
        a, b, c = map(int, input().split())
        a -= 1
        b -= 1
        G[a+N].append((b, c))
        G[b+N].append((a, c))

    T = list(map(int, input().split()))
    for i, t in enumerate(T):
        G[i].append((i+N, t))

    dist = [[inf] * 1001 for _ in range(N + N)]
    dist[0][0] = 0

    pq = [(0, 0, 0)]    # time, now, eat
    while pq:
        ds, s, P = heapq.heappop(pq)
        if dist[s][P] < ds:
            continue
        for t, dt in G[s]:
            if t == s + N and P + dt <= 1000:
                if dist[t][P + dt] > ds + dt:
                    dist[t][P + dt] = ds + dt
                    heapq.heappush(pq, (ds + dt, t, P + dt))
            else:
                if dist[t][P] > ds + dt // P:
                    dist[t][P] = ds + dt // P
                    heapq.heappush(pq, (ds + dt // P, t, P))

    ans = inf
    for i in range(1001):
        ans = min(ans, dist[N-1][i])
    print(ans)


main()
0