Updated Dynamic Programming. Made profit table based on lengths and
object ids