PRATA (Spoj) Problem

what may be the end condition for max time
i.e. how to find the worst-case time taken

@vivekpatel You just have to lower bound in the array.

@vivekpatel Iā€™m unable to understand your doubt

please see my code

@vivekpatel Accha for this if you are using binary search it would take nlogn time

@vivekpatel You are taking int as a data type take it long long as it may overflow

what is the problem in my code is my logic correct

even if I am taking not using long int then I am not getting correct answer

@vivekpatel Use long long int

I feel your logic is correct but your implementation might be wrong

sir please check the code

@vivekpatel since this is a really simple question I would recommend you to debug your errors yourself otherwise you will not learn.

Sir I have really tried for long time

Please give me hint other wise
I have to use long long int

@vivekpatel let me go through your code again. And do update the variables with long long int

1 Like

@vivekpatel the value of r which you are calculating is wrong.
R has to be lowestrank * ( prata*prata+1)/2

Sir can you explain me That I was asking at first

@vivekpatel Do check your code once again and do repeat silly mistakes like this.

1 Like

even now I am not getting correct answer

@vivekpatel Use long long int every place. Your answer might overflow. It is possible that you can get wrong answer because of that