You miss the point entirely.
It's not by man's consideration of justice that we are all (yes all) to be judged, but by God's consideration of what is just, and what is not.
If you look at Abraham's story, he is an impure person, and yet God judged him to be righteous.
How does that work?
How do the unrighteous become righteous in God's eyes?
Abraham believed God, and obeyed God, even to the intended sacrifice of his only son on the mountain to do as God said to do. Of course, if you read the story, you find that Abraham knew Isaac was "the son of promise" and that by Isaac, Abraham's nation would be great. He knew he would climb the mountain, and by some means would return with his son, even though his intent was to sacrifice his son to God.
(Genesis 22:5 Abraham said to his young men, “Stay here with the donkey, and I and the lad will go over there; and ---we will worship ---and return to you.”)
By acting out as God had commanded, Abraham showed his faith in God, that God would honor His commitment and not allow his "son of promise" to be extinguished without fulfilling His promise. He did not know how, but he trusted God, and acted on what God said he should do.
That (faith that was acted on) was counted to him as "righteousness."
Now, look at this in context with your question.
God is both loving, and just.
Justice is part of the necessity of whom He is.
He, loving the world allowed His only begotten Son to die on our place, so that He would not have to execute justice on those who had chosen NOT to do as they had been told.
What were we told?
To believe that the sacrifice of His Son was sufficient, to cover all sin, for all the world. The choice is simple.
Believe and be counted righteous.
Reject Him and be counted unrighteous, and subject to judgment.
This first verse is very familiar, but the following verses answer part of this question well.
John 3:16-20
New American Standard Bible (NASB)
16 “For God so loved the world, that He gave His only begotten Son, that whoever believes in Him shall not perish, but have eternal life.
17 For God did not send the Son into the world to judge the world, but that the world might be saved through Him.
18 He who believes in Him is not judged; he who does not believe has been judged already, because he has not believed in the name of the only begotten Son of God.
19 This is the judgment, that the Light has come into the world, and men loved the darkness rather than the Light, for their deeds were evil.
20 For everyone who does evil hates the Light, and does not come to the Light for fear that his deeds will be exposed.
Now as for all those "good deeds" we might do, or not do as we are given to what we are given:
Isaiah 64:6
For all of us have become like one who is unclean, And all our righteous deeds are like a filthy garment; And all of us wither like a leaf, And our iniquities, like the wind, take us away.
Titus 3:4-6
New American Standard Bible (NASB)
4 But when the kindness of God our Savior and His love for mankind appeared, 5 He saved us, not on the basis of deeds which we have done in righteousness, but according to His mercy, by the washing of regeneration and renewing by the Holy Spirit, 6 whom He poured out upon us richly through Jesus Christ our Savior,
So you see, it is God's provision for you, or it is no provision for you. What you do counts for little if you have not first considered to accept the provision made for you. To reject it is disobedience, and an affront to God, and a belittling of His Son's sacrifice.
In truth, the acceptance of Christ is the only way you can be sure your "good deeds" are being done to the ultimate good.