Whether mwy approach is correct or not?

i am finding maximum spanning tree using updated kruskals algorithm,and those edges which are not part of this spanning tree are edges which can be blocked by hackers ,and then just sorting the weights of these left edges and summing them up till the sum is less than s.

i was able to dio it on my own.