https://www.codechef.com/problems/DRGRAC

https://www.codechef.com/problems/DRGRAC

can someone please explain how to solve this question