Maximize Sum of Subsequence with Condition
Anonymous User
363

Given an array of integers, maximize the sum of a subsequence such that the sum of any two elements in the subsequence is greater than or equal to any other element. Return the sum of the subsequnce.

Constraints:
1 <= N <= 30000
0 <= A[i] <= 60000

Example:
A = [4, 4, 4, 5, 10]
Maximum sum = 17 for the subsequnce [4, 4, 4, 5]

An invalid subsequence would be [4, 4, 5, 10] since 4 + 5 < 10 and 4 + 4 < 10.

Comments (2)