Help Needed

How to solve this question…
Link - https://www.codechef.com/CJQK2020/problems/CJQK03
@tmwilliamlin @I_returns
Thanks.