Sort Descending, and create Prefix. Check positive count.
\nclass Solution {\npublic:\n    int maxScore(vector<int>& nums) {\n        sort(nums.begin(), nums.end(), greater<int>());\n        long long positiveSum = 0, 
```\nclass Solution {\npublic:\n    int maxScore(vector<int>& nums) {\n        sort(nums.begin(), nums.end(), greater<int>());\n        long long positiveSum = 0, ans = 0, n = nums.size();\n        vector<long long> prefSum(n);\n        prefSum[0] = nums[0];\n        for(int i = 1; i < n; ++i)  prefSum[i] = prefSum[i - 1] + nums[i];\n        for(int i = 0; i < n; ++i){\n            if(prefSum[i] <= 0) return i;\n            ans++;\n        }\n        return ans;\n    }\n};\n```\n\n\nCan also instead use single variable to keep track of prefix Sum, will reduce the space complexity to O(1)
['Sorting', 'Simulation', 'Prefix Sum', 'C++']