結果
問題 | No.748 yuki国のお財布事情 |
ユーザー | ckawatak |
提出日時 | 2018-12-29 17:29:56 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,370 bytes |
コンパイル時間 | 149 ms |
コンパイル使用メモリ | 13,056 KB |
実行使用メモリ | 57,344 KB |
最終ジャッジ日時 | 2024-10-01 19:42:03 |
合計ジャッジ時間 | 18,843 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 35 ms
11,264 KB |
testcase_01 | AC | 34 ms
11,264 KB |
testcase_02 | WA | - |
testcase_03 | AC | 38 ms
11,136 KB |
testcase_04 | AC | 34 ms
11,264 KB |
testcase_05 | AC | 33 ms
11,136 KB |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | AC | 33 ms
11,264 KB |
testcase_23 | AC | 33 ms
11,264 KB |
testcase_24 | AC | 33 ms
11,264 KB |
testcase_25 | WA | - |
testcase_26 | AC | 1,655 ms
54,272 KB |
testcase_27 | AC | 1,676 ms
54,272 KB |
testcase_28 | AC | 1,287 ms
41,856 KB |
ソースコード
from queue import PriorityQueue N,M,K = list(map(int, input().split(' '))) streets = [] for _ in range(N): streets.append([]) total_cost = 0 costs = [0 for _ in range(M)] for i in range(M): a, b, c = list(map(int, input().split(' '))) streets[a-1].append((i,b-1,c)) streets[b-1].append((i,a-1,c)) costs[i] = c total_cost = total_cost + c kept = [] for _ in range(K): e = int(input()) kept.append(e-1) included = [0 for _ in range(M)] key = [float('inf') for _ in range(N)] parent = [-1 for _ in range(N)] mst = [0 for _ in range(N)] que = PriorityQueue() que.put((0,0)) key[0] = 0 while not que.empty(): _,country_a = que.get() mst[country_a] = 1 for street in streets[country_a]: i, country_b, cost = street if mst[country_b] == 0 and cost < key[country_b]: key[country_b] = cost que.put((key[country_b],country_b)) parent[country_b] = country_a for i in range(1,N): for street in streets[i]: if street[1] == parent[i]: included[street[0]] = 1 cost = 0 for i in range(M): if included[i] == 1: cost = cost + costs[i] for i in kept: included[i] = 1 minimum_cost = 0 for i in range(M): if included[i] == 1: minimum_cost = minimum_cost + costs[i] print(total_cost - minimum_cost)