I can do it without using DP,
Logic-keep sorting and adding the first two numbers.
Time Complexity-O(N*logN * N)
But the problem is I’m getting WA in half of the test cases.
My Code:https://ide.codingblocks.com/s/300261
Please, check if my logic is wrong or the code!!