Can anybody help me with question from codeforces Div2 contest?

Question Link : https://codeforces.com/contest/1180/problem/B
Is there any algorithms used ?

this is just implementation bassed problem with greedy strategy see the tags

2 Likes

Change all +ve numbers to -ve (ie -a-1),
If n is odd find the largest element (magnitude wise) and change it to -a-1.
Dont forget to Handle the cases where answer can be zero. ie 0 0 0, or -1 0 -1 etc…

PS: keep track of their index. You have to print it in the same order as they were given…

Here’s my code for the problem, might help you. I think the code is easy enough for you to get it. try some raw inputs too.

https://codeforces.com/contest/1180/submission/55896840

I want to learn that greedy .

2 Likes

try questions on hackerearth

1 Like

Thanks i will definitely check them .

Dude… I gave you the solution: here

What did you not get ?

Me too …
from here we can start…