Bob is hosting a birthday party. He has called his friends and each friend will get a cake including bob so n cakes . there are m candles to be distributed among the cakes such that every cake has at least 1 candle and the difference in number of candles between any two neighbour is not greater than one . what can be the maximum number of candles bob can get. suppose bob is at kth(1-indexed) position . sample case n=6,m=28,k=5 then bob can get 6 candles at most

Auto comment: topic has been updated by Sanid (previous revision, new revision, compare).write a mathematical function say x is given to bob the people at distance one is given x-1 then at 2 x-2 so on.

My thoughts on this:

You should always do m-n to get everyone at 1 candle

After this you could add 1 to bob if you can(check his heighbors at first)

If you cant add any to his neighbors, go until you either fix that or run out of candels

And the answer should be arr[k-1]

Sorry, single_malt is right, i've got the question wrong