Discussion About Cover Them All!

This is Discussion thread about Cover Them All!

i tried to solve this problem by visiting the first soldier and comparing its distance with all other and every step I add the cost in the cost variable.
by this way I get the correct answer for the sample input. but when i submit the code I got wrong answer everywhere.