Kth root problem in searching and sorting problem

My solution is https://ide.codingblocks.com/s/213858
Can you tell me probem in this solution? I have used unsinged long long int still it is not working for larger inputs.

You just need to store ans as mid not max(ans,mid)

I have tried the suggested change but the problem still persists.