結果
問題 | No.748 yuki国のお財布事情 |
ユーザー | 夕叢霧香(ゆうむらきりか) |
提出日時 | 2018-10-19 21:49:55 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 129 ms / 2,000 ms |
コード長 | 950 bytes |
コンパイル時間 | 831 ms |
コンパイル使用メモリ | 85,872 KB |
実行使用メモリ | 5,660 KB |
最終ジャッジ日時 | 2023-08-12 00:49:17 |
合計ジャッジ時間 | 3,446 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge13 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
4,376 KB |
testcase_01 | AC | 2 ms
4,380 KB |
testcase_02 | AC | 2 ms
4,376 KB |
testcase_03 | AC | 1 ms
4,376 KB |
testcase_04 | AC | 2 ms
4,380 KB |
testcase_05 | AC | 1 ms
4,376 KB |
testcase_06 | AC | 2 ms
4,376 KB |
testcase_07 | AC | 2 ms
4,376 KB |
testcase_08 | AC | 2 ms
4,380 KB |
testcase_09 | AC | 2 ms
4,380 KB |
testcase_10 | AC | 2 ms
4,376 KB |
testcase_11 | AC | 2 ms
4,380 KB |
testcase_12 | AC | 2 ms
4,376 KB |
testcase_13 | AC | 14 ms
4,376 KB |
testcase_14 | AC | 26 ms
4,380 KB |
testcase_15 | AC | 18 ms
4,376 KB |
testcase_16 | AC | 48 ms
4,612 KB |
testcase_17 | AC | 98 ms
5,632 KB |
testcase_18 | AC | 113 ms
5,472 KB |
testcase_19 | AC | 129 ms
5,544 KB |
testcase_20 | AC | 115 ms
5,600 KB |
testcase_21 | AC | 107 ms
5,632 KB |
testcase_22 | AC | 2 ms
4,380 KB |
testcase_23 | AC | 2 ms
4,380 KB |
testcase_24 | AC | 2 ms
4,380 KB |
testcase_25 | AC | 86 ms
5,660 KB |
testcase_26 | AC | 105 ms
5,540 KB |
testcase_27 | AC | 102 ms
5,616 KB |
testcase_28 | AC | 89 ms
5,596 KB |
ソースコード
#include<algorithm> #include<iostream> #include<vector> using namespace std; typedef long long lint; typedef vector<int>vi; typedef pair<int,int>pii; typedef pair<lint,pii>edge; #define rep(i,n)for(int i=0;i<(int)(n);++i) const int N=110000; int par[N]; int root(int x){ if(x==par[x])return x; return par[x]=root(par[x]); } void unify(int x,int y){ x=root(x),y=root(y); par[x]=y; } int main(){ rep(i,N)par[i]=i; int n,m,k;cin>>n>>m>>k; vector<edge>es; lint sum=0; rep(i,m){ int a,b,c;cin>>a>>b>>c; es.push_back(edge(c,pii(a-1,b-1))); sum+=c; } vi e(k); lint ans=0; rep(i,k){ cin>>e[i],e[i]--; ans+=es[e[i]].first; unify(es[e[i]].second.first,es[e[i]].second.second); } sort(es.begin(),es.end()); rep(i,es.size()){ lint c=es[i].first; int a=es[i].second.first; int b=es[i].second.second; if(root(a)!=root(b)){ unify(a,b); ans+=c; } } cout<<sum-ans<<endl; }