C++ || O(1) Space
\n\n# Code\n\nclass Solution {\npublic:\n    int maxScore(vector<int>& nums) {\n        \n        sort(nums.begin(),nums.end(),greater<int>());\n\n        long 
\n\n# Code\n```\nclass Solution {\npublic:\n    int maxScore(vector<int>& nums) {\n        \n        sort(nums.begin(),nums.end(),greater<int>());\n\n        long long sum=0,ans=0;\n        int n=nums.size(),i;\n\n        //positive values\n        for(i=0;i<n;i++){\n            if(nums[i]<=0)\n                break;\n            sum += nums[i];\n        }\n        ans = i;\n        //non-positive values\n        while(i<n ){\n            sum += nums[i++];\n            if(sum > 0){\n                ans++;\n            }\n        }\n        return ans;\n    }\n};\n```
['C++']