結果
| 問題 | No.17 2つの地点に泊まりたい | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2020-05-21 21:31:34 | 
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 987 ms / 5,000 ms | 
| コード長 | 697 bytes | 
| コンパイル時間 | 89 ms | 
| コンパイル使用メモリ | 12,544 KB | 
| 実行使用メモリ | 56,504 KB | 
| 最終ジャッジ日時 | 2024-10-02 07:05:22 | 
| 合計ジャッジ時間 | 30,884 ms | 
| ジャッジサーバーID (参考情報) | judge5 / judge2 | 
| 外部呼び出し有り | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 27 | 
ソースコード
import numpy as np
from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson
from scipy.sparse import csr_matrix
n = int(input())
graph = [[0 for i in range(n)] for j in range(n)]
stay_cost = [int(input()) for i in range(n)]
for i in range(int(input())):
    a,b,c = map(int, input().split())
    graph[a][b] = graph[b][a] = c
graph = dijkstra(graph)
ans = 10**18
for i in range(1,n-1):
    for j in range(1,n-1):
        if i == j:
            continue
        #print("i:{} j:{}".format(i,j))
        ans = min(ans,
                  graph[0][i] + graph[i][j] + graph[j][n-1] +
                  stay_cost[i] + stay_cost[j] 
                )
print(int(ans))
            
            
            
        