Need help in Codeforces Snacktower

codeforces

#1

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…