結果

問題 No.17 2つの地点に泊まりたい
ユーザー ayaoniayaoni
提出日時 2020-12-04 11:08:36
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 97 ms / 5,000 ms
コード長 915 bytes
コンパイル時間 1,011 ms
コンパイル使用メモリ 86,648 KB
実行使用メモリ 76,876 KB
最終ジャッジ日時 2023-10-12 23:22:47
合計ジャッジ時間 4,756 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
71,152 KB
testcase_01 AC 73 ms
71,428 KB
testcase_02 AC 84 ms
75,900 KB
testcase_03 AC 89 ms
76,312 KB
testcase_04 AC 82 ms
76,216 KB
testcase_05 AC 96 ms
76,224 KB
testcase_06 AC 89 ms
76,400 KB
testcase_07 AC 84 ms
76,212 KB
testcase_08 AC 97 ms
76,876 KB
testcase_09 AC 96 ms
76,672 KB
testcase_10 AC 89 ms
76,324 KB
testcase_11 AC 90 ms
76,468 KB
testcase_12 AC 73 ms
71,232 KB
testcase_13 AC 75 ms
71,288 KB
testcase_14 AC 75 ms
71,452 KB
testcase_15 AC 73 ms
71,236 KB
testcase_16 AC 74 ms
71,400 KB
testcase_17 AC 82 ms
76,088 KB
testcase_18 AC 87 ms
75,928 KB
testcase_19 AC 87 ms
76,212 KB
testcase_20 AC 82 ms
76,352 KB
testcase_21 AC 79 ms
75,704 KB
testcase_22 AC 88 ms
76,232 KB
testcase_23 AC 91 ms
76,268 KB
testcase_24 AC 88 ms
76,380 KB
testcase_25 AC 78 ms
75,780 KB
testcase_26 AC 92 ms
75,956 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def LS2(): return list(sys.stdin.readline().rstrip())


N = I()
S = [I() for _ in range(N)]

inf = 10**18
dist = [[inf]*N for _ in range(N)]
M = I()
for _ in range(M):
    a,b,c = MI()
    dist[a][b] = c
    dist[b][a] = c

for k in range(N):
    for i in range(N):
        for j in range(N):
            dist[i][j] = min(dist[i][j],dist[i][k]+dist[k][j])

ans = inf
for i in range(1,N-1):
    for j in range(1,N-1):
        if i != j:
            ans = min(ans,dist[0][i]+dist[i][j]+dist[j][-1]+S[i]+S[j])

print(ans)
0