第三个这么做怎么样? ```c++ vector<int> nums = (4, -2, -11, -1, 4,1,-1}; int x = 10; int pre = 0, maxAns = nums[o]; for (const auto &i: nums) { int pre = pre; pre = max(pre + i, i); maxAns = findMax(pre, x + _pre, maxAns); //找这三个数的最大值 } cout<< maxAns; ```
点赞 3
牛客网
牛客企业服务