Question Link : Problem - B - Codeforces
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.
I want to learn that greedy .
2 Likes
try questions on hackerearth
1 Like
Thanks i will definitely check them .
Me too …
from here we can start…