結果
| 問題 | No.3653 Space-Time Courier |
| コンテスト | |
| ユーザー |
kidodesu
|
| 提出日時 | 2026-08-28 21:53:30 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 787 bytes |
| 記録 | |
| コンパイル時間 | 246 ms |
| コンパイル使用メモリ | 96,236 KB |
| 実行使用メモリ | 86,932 KB |
| 最終ジャッジ日時 | 2026-08-28 21:53:37 |
| 合計ジャッジ時間 | 6,433 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | TLE * 1 -- * 27 |
ソースコード
from heapq import *
n, m = list(map(int, input().split()))
A = list(map(int, input().split()))
node = [[] for _ in range(n)]
for _ in range(m):
u, v, w = list(map(lambda x: int(x)-1, input().split()))
w += 1
node[u].append((v, w))
inf = 1<<60
ans0 = inf+1
ans1 = 0
for s in range(n):
D = [inf]*n
D[s] = 0
hq = []
heappush(hq, (0, s))
while hq:
cost, u = heappop(hq)
if D[u] < cost: continue
for v, w in node[u]:
if D[v] > cost+w:
D[v] = cost+w
heappush(hq, (cost+w, v))
for v in range(n):
if s == v: continue
d = A[s]+A[v]+D[v]
#print(s, v, d)
if ans0 > d:
ans0, ans1 = d, 1
elif ans0 == d:
ans1 += 1
print(ans0, ans1)
kidodesu