Hello Everyone, Hope you all are doing well!
Problem: 2149A - Be Positive I was trying to solve this problem but got completely stuck. Then I looked at other people's submissions.
Submission: 340371416 I found this solution, and according to my understanding, it runs in 31ms. Most other solutions follow a similar idea, but I’m a bit confused about one part:
cout << z + ((on % 2) * 2) << endl;
I understand that z counts the number of zeros in the array and on counts the number of negative numbers. What I don’t understand is how this formula calculates the minimum number of positive 1s needed to make the product of all array elements positive.
Could someone please explain the logic behind z + ((on % 2) * 2) in simple words? It would help me a lot.
Thanks a lot for your time and help! Have a great day!



