Cyber Attack (MST)

please tell me what all kinds of test cases my code isnt able to handle bcoz then i will analyse and correct mistakes in my logic
AM FAILING 4 TEST CASES

my code:
https://ide.codingblocks.com/s/63622

question link:
https://hack.codingblocks.com/contests/c/511/871

Hi Jai, you seem to have given either question or code link of some other question or solution. Please share the correct links so that we can help you as soon as possible :slight_smile:

actually the contest has expired :sweat_smile:

question link:
https://hack.codingblocks.com/contests/c/511/871

my code:
https://ide.codingblocks.com/s/63622

these links are correct
i verified this just now

Hi Jai, u can solved greedily by finding Maximum Spanning Tree, MST(which can be found using minimum spanning tree algorithms). For the graph to remain connected, leave the edges of the MST. Now sort the remaining edges in the increasing order of their cost, remove the edges until the sum of costs of removed edges doesn’t exceed the allowed total cost, s.