Problem : Given a sequence a_{1}, a_{2}, …, a_{N}. Find the smallest possible value of a_{i} + a_{j}, where 1 ≤ i < j ≤ N

Explanation

This problem was the easiest one in the set and it was intended to enable everybody to get some points.

How to get 13 points

Here you have only two integers a_{1} and a_{2}, so the only possible sum will be a_{1}+a_{2}.

How to get 60 points

The constraints were designed in such a way that you can iterate through all the possible pairs (i, j), where 1 ≤ i < j ≤ N and check for every obtained sum, whether it’s the minimal one.

How to get 100 points

The answer is basically the sum of the minimal and the second-minimal element in the array. So you can simply iterate through all the numbers, keeping track of the minimal and the second-minimal number. Or if your programming language has built-in sorting, you can act even simpler, because after the sorting of the array in increasing order, the required minimal and the second-minimal will be the first and the second elements of the sorted array.

Sorting will increase the complexity to O(nlogn), but a simple approach will be of O(n) i.e. iterating through the elements once or twice. Hence I preferred O(n) approach!

Since your code does not work for n=2 also, there must be some problem in your input. I dont think that the complex things you did to ‘save’ space was needed at all.

Hey!. Congrats your problem is solved you didn’t put \n in printf due to which you were getting wa. But now 3 cases are solved and only 1 is left. So keep trying…