結果

問題 No.1690 Power Grid
ユーザー wolgnikwolgnik
提出日時 2021-09-24 22:44:28
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 655 bytes
コンパイル時間 321 ms
コンパイル使用メモリ 87,252 KB
実行使用メモリ 77,468 KB
最終ジャッジ日時 2023-09-18 21:52:38
合計ジャッジ時間 3,972 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,568 KB
testcase_01 AC 72 ms
71,528 KB
testcase_02 AC 72 ms
71,188 KB
testcase_03 AC 70 ms
71,380 KB
testcase_04 AC 71 ms
71,268 KB
testcase_05 AC 71 ms
71,264 KB
testcase_06 AC 117 ms
77,040 KB
testcase_07 AC 117 ms
77,324 KB
testcase_08 AC 118 ms
77,084 KB
testcase_09 AC 117 ms
76,684 KB
testcase_10 AC 77 ms
76,296 KB
testcase_11 AC 79 ms
76,200 KB
testcase_12 AC 72 ms
71,536 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 131 ms
76,756 KB
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 79 ms
76,468 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 72 ms
71,316 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
from itertools import combinations as combi
input = sys.stdin.readline
N, M, K = map(int, input().split())
a = list(map(int, input().split()))
d = [[10 ** 18] * N for _ in range(N)]
for i in range(M):
  u, v, c = map(int, input().split())
  d[u - 1][v - 1] = c
  d[v - 1][u - 1] = c

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

res = 10 ** 18
for c in combi(range(N), K):
  cres = 0
  for i in c[1: ]:
    t = 10 ** 18
    for j in c:
      if i == j: continue
      t = min(t, d[i][j])
    cres += t
  for i in c: cres += a[i]
  res = min(res, cres)
  #print(c, cres, d)
print(res)
0