The Monster
Can someone help me with the problem, http://codeforces.me/contest/918/problem/C, any help would be appreciated.