True way to solve it
Complexity

Time complexity: O(NLogN)


Space complexity: O(n)

Code
# Complexity
- Time complexity: $$O(NLogN)$$

- Space complexity: $$O(n)$$

# Code
```kotlin []
class Solution {
    fun maxScore(nums: IntArray): Int {
        val n = nums.size
        if (n == 0) return 0

        val prefix = LongArray(n) { i -> nums[i].toLong() }
        sort(prefix)

        var ans = if (prefix[0] > 0) 1 else 0
        for (i in 1 until n) {
            prefix[i] += prefix[i - 1]
            if (prefix[i] > 0L) ans++
        }  

        return ans
    }

    private fun sort(arr: LongArray) {
        val n = arr.size
        if (n < 2) return

        val mid = n / 2
        
        val leftHalf = arr.copyOfRange(0, mid)
        val rightHalf = arr.copyOfRange(mid, n)

        sort(leftHalf)
        sort(rightHalf)

        merge(arr, leftHalf, rightHalf)
    }

    private fun merge(arr: LongArray, leftHalf: LongArray, rightHalf: LongArray) {
        val m = leftHalf.size
        val n = rightHalf.size

        var i = 0
        var l = 0
        var r = 0

        while (l < m && r < n) {
            if (leftHalf[l] >= rightHalf[r]) {
                arr[i++] = leftHalf[l++]
            } else {
                arr[i++] = rightHalf[r++]
            }
        }

        while (l < m) {
            arr[i++] = leftHalf[l++]
        }

        while (r < n) {
            arr[i++] = rightHalf[r++]
        }
    }
}
```
['Array', 'Sorting', 'Merge Sort', 'Prefix Sum', 'Kotlin']