TLE in test case 4

link to my code https://ide.codingblocks.com/s/336404

use long everywhere to avoid overflow.that ll pass the test case
please marks your doubt as resolved

I have used long where ever possible but still it is giving tle

use priority queue .it ll easily pass all the test cases .
refer to this