Simplest C++ Solution
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```cpp []\nclass Solution {\npublic:\n    long long maximumTotalCost(vector<int>& nums) {\n        vector<long long int>dp(nums.size()+1,0);\n        //hrer state fxn is till size i max sum\n        dp[1]=nums[0];\n        for(int i=2;i<dp.size();i++){\n            if(nums[i-1]>=0) dp[i]=dp[i-1]+nums[i-1];\n            else{\n                if(nums[i-2]>0) dp[i]=dp[i-2]+nums[i-2]+abs(nums[i-1]);\n                else dp[i]=max(dp[i-2]+nums[i-2]+abs(nums[i-1]),dp[i-1]+nums[i-1]);\n            }\n        }\n        return dp[nums.size()];\n    }\n};\n```
['C++']