Efficient Solution Using C#
Complexity
Time complexity:
O(1)
Space complexity:
O(n)
Code
# Complexity
- Time complexity:
O(1)
- Space complexity:
O(n)

# Code
```csharp []
public class Solution {
    public int MaxScore(int[] nums) {
        // Sort the numbers in descending order to maximize the prefix sums staying positive
        Array.Sort(nums, (a, b) => b.CompareTo(a));
        
        long sum = 0; // use long to handle large sums
        int count = 0;

        // Calculate prefix sums directly during one pass through the array
        for (int i = 0; i < nums.Length; i++) {
            sum += nums[i];
            // If the current prefix sum is positive, increment the count
            if (sum > 0) {
                count++;
            }
        }

        return count;
    }
}

```
['C#']