input: Write a Python function that takes an integer array (nums) and returns the highest possible total cost after optimally splitting the array into multiple subarrays. Ensure each element belongs to one subarray exactly. The cost of any subarray nums[l..r] is computed as: cost(l, r) = nums[l] - nums[l + 1] + ... + nums[r] * (−1)^(r − l). If the array is not split, the total cost is the cost of the entire array.
output: def maxSubarrayCost(nums):
      n = len(nums)
      if n == 1:
          return nums[0]
      dp = [[0] * n for _ in range(n)]
      for i in range(n):
          dp[i][i] = nums[i]
      for l in range(2, n + 1):
          for i in range(n - l + 1):
              j = i + l - 1
              dp[i][j] = nums[i] - dp[i + 1][j]
      max_cost = float('-inf')
      for i in range(n):
          for j in range(i, n):
              max_cost = max(max_cost, dp[i][j])
      return max_cost