Help me in question CRISIS

,

Can someone explain me how to approach this problem from code melange?
https://www.codechef.com/CMEL2018/problems/CRISIS