SRM 772 Div-2 250*

can anyone please help me out with this problem…

https://community.topcoder.com/stat?c=problem_statement&pm=15777&rd=17746&rm=&cr=22926380