ICM2004 Editorial

can some one explain how to approach this problem. I am solving it with Brute force which gives TLE.

Problem

My code :

1 Like