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

link to the problem : http://codeforces.com/contest/589/problem/B

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