codejam1 maxperiod

this is codejam1 solution.