FB hacker cup and SRM637 div1 q1

SRM637 question 1 GreaterGame
codechef ORDERS problem