Approach of the problem

Can anyone tell me how to approach this problem?

Every successful submissions have used a similar approach and I am unable to understand it.

CodeChef: Practical coding for everyone refer this problem from one the previous lunch time.