The problem is in Vietnamese, and this is a translation. I will post the original problem in Vietnamese below.
There are n steps and for each step d[i] (1<=i<=n), we can move left or right d[i] ( unit ).
The question is to find an optimal way of movements that the distance from the farthest right position to the farthest left position after finishing n steps is smallest.
There are T tests ( T<=80), each test contains a number n ( number of steps ) and followed by n d[i] ( unit )
we just need to print one possible solution that the difference of the rightest and leftest position is minimum
- 40% test cases that n<=16 and 1<=d[i]<=800
- 30% test cases that n<=800 and 1<=d[i]<=16
- 30% test cases that n<=800 and 1<=d[i]<=800
10 3 5
0 -> 10 -> 7 -> 2
so the rightest position is 10 and the leftest is 0 ( 10 - 0 = 10 . in this case, 10 is the smallest difference )