50.45%
class Solution {
public:
int maxSubArray(vector<int>& nums) {
int maxSum=nums[0];
int dp[nums.size()];//以当前字符串为最后一个字符串的子字符串最大和
dp[0]=nums[0];
for (int i=1;i<nums.size() ;i++ )
{
dp[i]=nums[i]+(dp[i-1]>0?dp[i-1]:0);
maxSum=max(dp[i],maxSum);
}
return maxSum;
}
};