COG1803 - Editorial

PROBLEM LINK:

Practice

Contest

Author: Arjun Jaiswal

Editorialist: Pawan Mishra

DIFFICULTY:

CAKEWALK

PROBLEM:

N people take part in voting process in a bid to Rename the krypton city. People cast their vote in form of 1, -1 or 0 showing that they support, oppose and are neutral to name change process, respectively. Print “YES” if the city will be renamed else “NO”.

EXPLANATION:

City will be renamed if number of 1’s are greater than or equal to number of -1’s, that is if no of people supporting renaming are greater than or equal in number to those against it.
Count the number of 1’s and number of -1’s and compare them.

Alternatively, simply add the input votes. Finally, if sum is greater than or equal to 0, then ans is “YES” else “NO”.

AUTHOR’S AND TESTER’S SOLUTIONS:

Author’s solution can be found here.

Little Appreciation Keeps us Motivated.

1 Like

1 means in favor of changing the name, -1 against it and 0 neutral

So I thing if no. Of 1’s are greater than or equals to no. Of -1’s then output should be YES otherwise NO

We have nothing to do with 0

Sorry, that was a silly mistake. Corrected it. Thanks for pointing that out.