結果

問題 No.1449 新プロランド
ユーザー tamatotamato
提出日時 2021-03-31 16:03:20
言語 PyPy3
(7.3.15)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 1,413 bytes
コンパイル時間 414 ms
コンパイル使用メモリ 87,672 KB
実行使用メモリ 93,364 KB
最終ジャッジ日時 2023-08-25 16:49:54
合計ジャッジ時間 7,116 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 87 ms
76,656 KB
testcase_01 AC 123 ms
78,928 KB
testcase_02 AC 158 ms
80,716 KB
testcase_03 AC 94 ms
77,064 KB
testcase_04 AC 132 ms
78,800 KB
testcase_05 AC 279 ms
93,136 KB
testcase_06 AC 251 ms
88,016 KB
testcase_07 AC 209 ms
85,864 KB
testcase_08 AC 250 ms
90,684 KB
testcase_09 AC 222 ms
84,948 KB
testcase_10 AC 231 ms
88,436 KB
testcase_11 AC 204 ms
86,896 KB
testcase_12 AC 257 ms
90,176 KB
testcase_13 AC 224 ms
84,120 KB
testcase_14 AC 189 ms
85,956 KB
testcase_15 AC 271 ms
89,732 KB
testcase_16 AC 235 ms
85,924 KB
testcase_17 AC 234 ms
86,516 KB
testcase_18 AC 83 ms
76,308 KB
testcase_19 AC 91 ms
77,336 KB
testcase_20 AC 81 ms
75,656 KB
testcase_21 AC 213 ms
85,928 KB
testcase_22 AC 175 ms
79,676 KB
testcase_23 AC 245 ms
90,880 KB
testcase_24 AC 200 ms
82,708 KB
testcase_25 WA -
testcase_26 AC 110 ms
78,296 KB
testcase_27 AC 293 ms
93,364 KB
testcase_28 AC 240 ms
87,320 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

mod = 1000000007
eps = 10**-9


def main():
    import sys
    input = sys.stdin.readline
    import heapq

    def dijkstra(adj, start):
        # adj: [[to, cost] * vertices], 0th index must be empty
        inf = 1 << 60
        dist = [inf] * len(adj)
        dist[start] = 0
        q = []
        heapq.heappush(q, (0, start))
        while q:
            min_dist, v_from = heapq.heappop(q)
            if min_dist > dist[v_from]:
                continue
            v_tos = adj[v_from]
            for v_to, cost in v_tos:
                if min_dist + cost < dist[v_to]:
                    dist[v_to] = min_dist + cost
                    heapq.heappush(q, (dist[v_to], v_to))
        return dist

    N, M = map(int, input().split())
    adj = [[] for _ in range(N * 1001 + 1)]
    ABC = []
    for _ in range(M):
        ABC.append(tuple(map(int, input().split())))
    T = [0] + list(map(int, input().split()))
    for a, b, c in ABC:
        ta = T[a]
        tb = T[b]
        for p in range(1001):
            if 0 < ta + p <= 1000:
                adj[a + N * p].append((b + N * (p + ta), c // (p + ta) + ta))
            if 0 < tb + p <= 1000:
                adj[b + N * p].append((a + N * (p + tb), c // (p + tb) + tb))
    dist = dijkstra(adj, 1)
    ans = float("inf")
    for p in range(1001):
        ans = min(ans, dist[N + N * p])
    print(ans)


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