Please provide some hint
Can you give me some hint?
@raj.verma5454
what if A<=B, then it is obvious to make temple in every city!
but for A>B, you may make temple in a city and repair roads such that maximum city are connected to this city! Actually this now becomes a connected components graph problem.
Got it . for case (A>B) It’s like for every connected component we build temple and rest are roads. And for case 1 it is clear that we can build temple in each city for minimizing the cost. Thanks for the explanation. 
can you please check my dijkstra’s code it is giving wrong answer and TA is not responding from 17 hours.
Code is fine, just take care of overflow!, take ans of type long long.
thanks . Please see this code as well of dijkastra’s . Ta is not replying . https://ide.codingblocks.com/s/259116
@raj.verma5454 whenever such thing happens that a doubt is fully not resolved, you can always reopen the doubt!, I advice you to do same.
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.