Given the array nums, obtain a subsequence of the array whose sum of elements is strictly greater than the sum of the non&nbsp;included elements in such subsequence.&nbsp;

If there are multiple solutions, return the subsequence with minimum size and if there still exist multiple solutions, return the subsequence with the maximum total sum of all its elements. A subsequence of an array can be obtained by erasing some (possibly zero) elements from the array.&nbsp;

Note that the solution with the given constraints is guaranteed to be&nbsp;unique. Also return the answer sorted in non-increasing order.

&nbsp;
Example 1:

Input: nums = [4,3,10,9,8]
Output: [10,9] 
Explanation: The subsequences [10,9] and [10,8] are minimal such that the sum of their elements is strictly greater than the sum of elements not included. However, the subsequence [10,9] has the maximum total sum of its elements.&nbsp;


Example 2:

Input: nums = [4,4,7,6,7]
Output: [7,7,6] 
Explanation: The subsequence [7,7] has the sum of its elements equal to 14 which is not strictly greater than the sum of elements not included (14 = 4 + 4 + 6). Therefore, the subsequence [7,6,7] is the minimal satisfying the conditions. Note the subsequence has to be returned in non-decreasing order.  


&nbsp;
Constraints:


	1 &lt;= nums.length &lt;= 500
	1 &lt;= nums[i] &lt;= 100


class Solution:
    def minSubsequence(self, nums: List[int]) -> List[int]:
        nums.sort(reverse=True)
        val = sum(nums)
        temp = []
        for i in range(len(nums)):
            temp.append(nums[i])
            if sum(temp)>val-sum(temp):
                return temp
            
class Solution {
    public List<Integer> minSubsequence(int[] nums) {
        int total = 0;
        for(int i=0;i<nums.length;i++){
            total += nums[i];
        }
        Arrays.sort(nums);
        int sum = 0;
        ArrayList<Integer> ans = new ArrayList<>();
        for(int i=nums.length-1;i>=0;i--){
            ans.add(nums[i]);
            sum += nums[i];
            if(sum>total-sum){
                return ans;
            }
        }
        return ans;
    }
}
class Solution {
public:
    vector<int> minSubsequence(vector<int>& nums) {
        
        sort(nums.begin(), nums.end(),greater<int>());
        vector<int> res;
        int sum = 0;
        for(int i: nums)
            sum += i;
        
        int x=0;
        for(int i=0; i<nums.size(); i++)
        {
            x += nums[i];
            sum -= nums[i];
            res.push_back(nums[i]);
            if(x>sum)
                break;
            
        }
        return res;
    }
};
/**
 * @param {number[]} nums
 * @return {number[]}
 */
var minSubsequence = function(nums) {
  const target = nums.reduce((a, b) => a + b) / 2;
  nums.sort((a, b) => b - a);
  let i = 0, sum = 0;
  while (sum <= target) {
    sum += nums[i++];
  }
  return nums.slice(0, i);
};
Minimum Subsequence in Non-Increasing Order