結果

問題 No.748 yuki国のお財布事情
ユーザー twkmathtwkmath
提出日時 2018-10-21 12:51:16
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 658 bytes
コンパイル時間 377 ms
コンパイル使用メモリ 10,892 KB
実行使用メモリ 114,508 KB
最終ジャッジ日時 2023-08-12 05:40:56
合計ジャッジ時間 5,444 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 18 ms
15,008 KB
testcase_01 WA -
testcase_02 AC 17 ms
7,796 KB
testcase_03 AC 16 ms
7,872 KB
testcase_04 AC 16 ms
7,836 KB
testcase_05 AC 16 ms
7,904 KB
testcase_06 AC 16 ms
7,876 KB
testcase_07 AC 16 ms
7,872 KB
testcase_08 AC 16 ms
7,828 KB
testcase_09 AC 16 ms
7,872 KB
testcase_10 AC 16 ms
7,824 KB
testcase_11 AC 16 ms
7,960 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 TLE -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

N,M,K=[int(i) for i in input().split()]
e=[];t=set();s=0
for j in range(M):
	a,b,c=[int(i) for i in input().split()]
	e.append((c,a,b))
	s+=c
o=sorted(e)
p=[]
for j in range(K):
	i=int(input())-1
	t.add(i)
	a,b=e[i][1:3]
	x=-1;y=-1
	for k,q in enumerate(p):
		if a in q: x=k
		if b in q: y=k
	if x<0 and y<0: p.append({a,b})
	elif x<0: p[y].add(a)
	elif y<0: p[x].add(b)
	elif x!=y: p[x]|=p[y]#; del p[y]
	s-=e[i][0]
for f in o:
	a,b=f[1:3]
	x=-1;y=-1
	for k,q in enumerate(p):
		if a in q: x=k
		if b in q: y=k
	if x<0 and y<0: p.append({a,b})
	elif x<0: p[y].add(a)
	elif y<0: p[x].add(b)
	elif x!=y: p[x]|=p[y]#; del p[y]
	else: continue
	s-=f[0]
print(s)
0