HackerEarth Rolling Balls problem solution - TheCScience