Maimonides teaches us (Hilchot Teshuvah 3:1-3): Every man has both sins and sources of merit. If his merits are greater than his transgressions, he is considered to be entirely righteous.

If his transgressions are greater, he is considered to be entirely wicked. And if his sins and merits are equal, he is referred to as one who is in the middle, the same is true as concerns an entire country. If the collective merit of all of the residents is greater than their sins, the people are considered to be righteous. If their collective sins are greater, they are considered to be wicked. And the same holds true for the entire world.

If a person's sins are greater than his sources of merit, he immediately perishes because of his wickedness, as the verse (Jeremiah 30:14) states:
Because of the enormity of your sins.
Similarly, if a country's sins are greater, it is immediately destroyed, as the verse (Genesis 18:20) states:
For the outcry from S'dom and Amorah is great.

And the same applies to the entire world: If the transgressions are greater than the sources of merit, it is immediately brought to ruin, as the verse (ibid. 6:5) states:
And G‑d saw that man's evil was great.

However, this judgment is not quantitative; rather it is qualitative. There are individual acts of merit which are considered weightier than many sins, as the verse (Kings I; 14:13) states:
Perhaps we shall find something good.
Similarly, there are sins that can outweigh many sources of merit, as the verse (Kohelet 9:18) states:
And one sinner can cause much good to be lost.

The determination is dependent solely upon the judgment of G‑d Whose knowledge is all-encompassing, for only He can evaluate merit and sin.

Each person should therefore see himself, during the entire year, as if he were half meritorious and half guilty. Likewise should he consider the entire world as half meritorious and half guilty? Thus if he commits one single sin, he is capable of tipping the scale of transgression for himself and the entire world, causing its destruction as well as his own.

Likewise, if he performs one mitzvah, he can tip the scale of merit for himself and for the entire world, causing its salvation and deliverance, as well as his own - as the verse (Proverbs 10:25) states:
And the righteous man is the foundation of the world
- i.e., because he is a tzaddik, he tips the scale of the world to the side of merit and saves it [from destruction].