Little monk meet virat ( heap question)

https://hack.codingblocks.com/contests/c/471/1627
above is link to the question of heaps for which i have written following code :
https://ide.codingblocks.com/#/s/29345

please help me with output as i am getting output for sample input but at the time of submitting getting wrong answer. thanks

https://ide.codingblocks.com/#/s/29429

long long arrays were required, and a small bug at the end. I have marked and corrected it.