Rom 5:8 But God demonstrates his own love for us, in that while we were still sinners, Christ died for us.
Rom 5:9 Much more then, because we have now been declared righteous by his blood, we will be saved through him from God's wrath.
Rom 5:10 For if while we were enemies we were reconciled to God through the death of his Son, how much more, since we have been reconciled, will we be saved by his life?
Note that while we were helpless ungodly sinners who were enemies, Christ died for us, been declared righteous by his blood, will be saved from God's wrath, and we were reconciled to God through the death of His Son
At the foot of the cross were many helpless ungodly sinners who were the enemies of Jesus, yet He said, "Father forgive them for they don't know what they are doing". I believe the Father was in agreement with this prayer of Jesus and so their sins were or will be forgiven on the merits of Jesus alone. Mankind was declared righteous, or justified on that day as confirmed by verse 18.
Rom 5:18 Consequently, just as one offense resulted in condemnation for everyone, so one act of righteousness results in justification and life for everyone.