Topcoder SRM answer