#C6703. Taco - Maximum Sum after One Operation
Taco - Maximum Sum after One Operation
Taco - Maximum Sum after One Operation
Given an array of positive integers, your task is to determine the maximum possible sum obtainable by selecting two distinct elements from the array. In other words, for each test case, you need to output the sum of the two largest numbers in the array.
For example, if the array is [1, 2, 3], the answer is 5 because 2 and 3 are the two largest numbers and their sum is 5. This problem involves simple array manipulation and sorting. The time complexity is mainly dominated by sorting the list, which operates in O(n \log n) time, where (n) is the number of elements in the array.
inputFormat
The first line of input contains an integer (t) representing the number of test cases. For each test case, the first line contains an integer (n) (the number of elements in the array) and the next line contains (n) space-separated positive integers representing the array elements.
outputFormat
For each test case, output a single line containing the maximum sum obtainable by adding the two largest distinct numbers in the corresponding array.## sample
2
3
1 2 3
4
10 20 30 40
5
70
</p>