結果
問題 | No.788 トラックの移動 |
ユーザー | roaris |
提出日時 | 2020-12-03 10:12:09 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 955 bytes |
コンパイル時間 | 306 ms |
コンパイル使用メモリ | 87,000 KB |
実行使用メモリ | 113,476 KB |
最終ジャッジ日時 | 2023-10-11 19:04:08 |
合計ジャッジ時間 | 14,145 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | TLE | - |
testcase_01 | AC | 81 ms
71,520 KB |
testcase_02 | AC | 80 ms
71,480 KB |
testcase_03 | AC | 80 ms
71,120 KB |
testcase_04 | AC | 583 ms
86,368 KB |
testcase_05 | TLE | - |
testcase_06 | TLE | - |
testcase_07 | AC | 81 ms
71,520 KB |
testcase_08 | AC | 80 ms
71,320 KB |
testcase_09 | AC | 79 ms
71,392 KB |
testcase_10 | AC | 80 ms
71,376 KB |
testcase_11 | AC | 80 ms
71,520 KB |
testcase_12 | AC | 81 ms
71,236 KB |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | AC | 561 ms
110,100 KB |
testcase_16 | TLE | - |
ソースコード
import sys input = sys.stdin.readline from heapq import * def dijkstra(s): dist = [10**18]*N dist[s] = 0 pq = [] heappush(pq, (0, s)) while pq: d, v = heappop(pq) if dist[v]<d: continue for nv, w in G[v]: if dist[nv]>dist[v]+w: dist[nv] = dist[v]+w heappush(pq, (dist[nv], nv)) return dist N, M, L = map(int, input().split()) t = list(map(int, input().split())) G = [[] for _ in range(N)] for _ in range(M): a, b, c = map(int, input().split()) G[a-1].append((b-1, c)) G[b-1].append((a-1, c)) D = [dijkstra(i) for i in range(N)] ans = 10**18 for i in range(N): base = 0 for j in range(N): base += 2*t[j]*D[i][j] for j in range(N): cand = base+D[L-1][j]+D[j][i] if t[j]>=1: cand -= 2*D[i][j] ans = min(ans, cand) print(ans)