HackerEarth The weighted graph problem solution - TheCScience