Greedy and Simple
Code\n\nclass Solution {\npublic:\n    long long minSum(vector<int>& nums1, vector<int>& nums2);\n};\n\nlong long Solution::minSum(vector<int>& nums1, vector<in
# Code\n```\nclass Solution {\npublic:\n    long long minSum(vector<int>& nums1, vector<int>& nums2);\n};\n\nlong long Solution::minSum(vector<int>& nums1, vector<int>& nums2) {\n    auto getSumAndZeros = [](const vector<int>& nums) -> pair<long long, unsigned int> {\n        pair<long long, unsigned int> sumAndZeros = {0, 0};\n        for (auto num: nums) {\n            sumAndZeros.first += num;\n            if (num == 0) {\n                sumAndZeros.second++;\n            }\n        }\n        return sumAndZeros;\n    };\n\n    auto [sumNums1, zeroesNums1] = getSumAndZeros(nums1);\n    auto [sumNums2, zeroesNums2] = getSumAndZeros(nums2);\n    if (zeroesNums1 == 0 && (sumNums1 < sumNums2 + zeroesNums2) ||\n        zeroesNums2 == 0 && (sumNums2 < sumNums1 + zeroesNums1)) {\n        return -1;\n    }\n    return max({\n        sumNums1 + zeroesNums1,\n        sumNums2 + zeroesNums2\n    });\n}\n```
['C++']