The problem look like this : we have n object each object have a weight .
We want to create 2 groups of these objects so the number of objects on the two groups must not differ by more than 1 and the total weight of the objects on each group should be as nearly equal as possible.
examples :
n = 4 : 1 2 3 4 => ans : 5 5
n = 4 : 1 2 3 11111 => ans : 5 11112
n = 3 : 100 90 200 => ans :190 200
my code works fine for small input how ever it gives negative values for large input (n >= 25 ) . My code
You should now that n<=100 and the sum of weights is <= 1e6 .