結果

問題 No.748 yuki国のお財布事情
ユーザー twkmathtwkmath
提出日時 2018-10-21 12:50:05
言語 Python3
(3.11.6 + numpy 1.26.0 + scipy 1.11.3)
結果
WA  
実行時間 -
コード長 660 bytes
コンパイル時間 101 ms
コンパイル使用メモリ 10,916 KB
実行使用メモリ 18,040 KB
最終ジャッジ日時 2023-08-12 05:40:50
合計ジャッジ時間 5,351 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
12,248 KB
testcase_01 WA -
testcase_02 AC 18 ms
7,840 KB
testcase_03 AC 17 ms
7,780 KB
testcase_04 AC 16 ms
7,824 KB
testcase_05 WA -
testcase_06 AC 16 ms
7,952 KB
testcase_07 AC 16 ms
7,784 KB
testcase_08 AC 16 ms
7,832 KB
testcase_09 AC 17 ms
7,868 KB
testcase_10 AC 17 ms
7,940 KB
testcase_11 AC 16 ms
7,752 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