How to solve problem Layer Cake from 2015-16 ACM ICPC NEERC ?

link to the problem : Login - Codeforces

I’m not able to think of any approach for this, I have seen some solutions (code), but I’m still not able to understand.

1 Like