Hi there,
I am trying to solve this problem : http://codeforces.net/contest/302/problem/C, however even on reading the editorial I am not able to get how to solve it.
Editorial says that it can be solved using dfs but I am not even able to figure out the graph in the problem.
Further, most of solutions I have read are doing this :
if((n is odd) || (n is even and #negatives is even))
ans= sum of absolute values of all numbers
else
ans=sum of absolute values of all numbers-2*(abs(element with minimum absolute value))
``
Can you please help me in understanding how this is working and how to apply dfs in this ?
Thanks in advance.
I don't understand why you need dfs in this problem either. It can be solved with pure bruteforce. You can see my solution, maybe it will be helpful: 9638601