I have issue in question named as C. Rumor -893C, link :- https://codeforces.com/problemset/problem/893/C. I think that i have understand the questions basic as we have to find number of component in graph with minimum price of component and simply we have to do addition i on them. I have come up with pretty good solution but test case 8 getting fail. can you help me where is the problem lies in my code.

# include<bits/stdc++.h>

using namespace std;

typedef long long ll;

int solve(){ ll n,m; cin>>n>>m; ll a[n]; for(ll i=0;i<n;i++) cin>>a[i]; for(ll i=0;i<m;i++){ ll x,y; cin>>x>>y; x--;y--; ll t=min(a[x],a[y]); a[x]=t; a[y]=0; } ll res=0; for(ll i=0;i<n;i++) res+=a[i]; cout<<res<<endl; return 0; }

int main(){ ll t=1; //cin>>t; while(t--) solve(); return 0; }

• -2

 » 11 days ago, # |   0 Auto comment: topic has been updated by adityav664 (previous revision, new revision, compare).
 » 11 days ago, # |   +3 Format your code for christsake, no one will read that
 » 11 days ago, # | ← Rev. 2 →   0 What the heck!! Your code seems like a shit!!It is already unreadable if you don't know how to write a blog learn from someone or just stop shitting around you . The pattern is following: first you you write "  " without quotes in start and in end of code. example : note : quotes are for example." "print("Hello world!")" " it will look like this print("Hello world!") 
 » 11 days ago, # | ← Rev. 4 →   0 The idea is correct but your implementation seems wrong to me.You have just considered every edge and made one of them equal to min(first, second) while making the other one $0.$ Do you think it will actually work? HintWhen you make vertex $x$ cost = $min($ $c_x$, $c_y$ $)$ and vertex $y$ cost = $0$, you are actually saying that the minimum cost vertex for this component must not be connected to $y$. (as you made $c_y$ $= 0$ which is less than any possible vertex cost. Test Case (Don't see before understanding the hint)3 2 5 6 1 1 2 2 3 
•  » » 11 days ago, # ^ |   0 thanks i understand now
 » 11 days ago, # |   0 It's my first time for post so sorry for that
•  » » 11 days ago, # ^ |   0 I think you can just remove your code. The submission link is enough. Also if your doubt is resolved just write [SOLVED] or [RESOLVED]` at the start of topic so people know your doubt has been cleared.
•  » » » 11 days ago, # ^ |   0 Thanks
 » 11 days ago, # |   0 This is my submission: 167158337.
•  » » 11 days ago, # ^ |   0 Got It