結果

問題 No.17 2つの地点に泊まりたい
ユーザー roiti46roiti46
提出日時 2015-02-16 00:48:58
言語 Python2
(2.7.18)
結果
WA  
実行時間 -
コード長 535 bytes
コンパイル時間 73 ms
コンパイル使用メモリ 6,708 KB
実行使用メモリ 6,144 KB
最終ジャッジ日時 2023-09-06 01:33:01
合計ジャッジ時間 2,477 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 12 ms
5,948 KB
testcase_01 AC 11 ms
5,932 KB
testcase_02 AC 13 ms
5,872 KB
testcase_03 AC 70 ms
6,108 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 27 ms
5,936 KB
testcase_08 AC 74 ms
5,892 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 11 ms
5,992 KB
testcase_13 AC 11 ms
5,888 KB
testcase_14 AC 11 ms
6,008 KB
testcase_15 AC 11 ms
5,932 KB
testcase_16 AC 12 ms
5,896 KB
testcase_17 AC 18 ms
5,956 KB
testcase_18 AC 57 ms
6,136 KB
testcase_19 AC 53 ms
5,956 KB
testcase_20 AC 16 ms
6,116 KB
testcase_21 AC 13 ms
5,868 KB
testcase_22 AC 63 ms
6,144 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 12 ms
5,984 KB
testcase_26 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

inf = 10**9

N = int(raw_input())
S = [int(raw_input()) for i in xrange(N)]
M = int(raw_input())
d = [[inf]*N for i in xrange(N)]
for loop in xrange(M):
    A,B,C = map(int,raw_input().split())
    d[A][B] = d[B][A] = C
    
for i in xrange(N):
    for k in xrange(N):
        for j in xrange(N):
            d[i][j] = min(d[i][j], d[i][k]+d[k][j])
ans = inf
for i in xrange(1,N-1):
    for j in xrange(i+1,N-1):
        cost = S[i]+S[j]+min(d[0][i]+d[i][j]+d[j][N-1],d[0][j]+d[j][i]+d[i][N-1])
        ans = min(ans, cost)
print ans

0