Masked House Robber
I did not recognize the hourse robber at first.\n\nWhen we see a positive number, we just take it (starting a new subarray).\n\nFor a streak of negative numbers
I did not recognize the hourse robber at first.\n\nWhen we see a positive number, we just take it (starting a new subarray).\n\nFor a streak of negative numbers, we can flip some of them to positive. \n\nHowever, we cannot flip two numbers if they are next to each other.\n- The house robber algorithm can find the maximum value we can flip (steal) with this restriction.\n\n> Note that we need to add the **double** of the flipped value to the sum of all numbers.\n> Also note that we cannot flip the very first negative number.\n\n**C++**\n```cpp\nlong long maximumTotalCost(vector<int>& nums) {\n    long long cur = 0, prev = 0;\n    for (int i = 1; i < nums.size(); ++i)\n        cur = exchange(prev, max(cur, prev)) - nums[i];\n    return accumulate(begin(nums), end(nums), 0LL) + 2LL * max(cur, prev);\n}\n```\n\n#### Original Version\nThe equivalent original code, which follows the description above more closelly.\n\n**C++**\n```cpp\nlong long maximumTotalCost(vector<int>& nums) {\n    long long res = nums[0], cur = 0, prev = 0;\n    for (int i = 1; i < nums.size(); ++i) {\n        res += nums[i];\n        if (nums[i] >= 0) {\n            res += 2LL * max(cur, prev);\n            cur = prev = 0;\n        }\n        else\n            cur = exchange(prev, max(cur, prev)) - nums[i];\n    }\n    return res + 2LL * max(cur, prev);\n}\n```
['C']