Need help in Codeforces Snacktower

I read the editorial but am not able to come up with a solution for this problem http://codeforces.com/problemset/problem/767/A. Can anyone help me out here…