Solved 1282 problem

	Using method of dynamic programming