CAN ANYONE PLEASE TELL ME HOW DO I APPLY THE CONSTRAINTS ?


This is the link of the question. Even though output is desired one i still got 13 points out of 100. I think it is because of constraints. I don’t really get the concept of constraint. Can somebody help?

T = 105, N = 2 : 13 points.
T = 105, 2 ≤ N ≤ 10 : 16 points.
T = 1000, 2 ≤ N ≤ 100 : 31 points

.
O(n^2) shall do, but when u go for 10^5 max u can go is n log n or n log n log n in some cases if the constraints are weak. u need to basically an order of 10^6 it should suffice.
in this question see you cannot just iterate i from 1-n and then j from i+1 to n , that will take n^2. so just sort it and your answer wil be
a[0]+a[1]

in c++ use the inbuilt function sort(a,a+n)

in java use Arrays.sort(a)
in python a.sort()

it does in n log n

THANK YOU …IT WORKS FINE NOW