use dp to resolve max subarray problem