See Revelation 20:11–15. It is commonly called the Judgment of the Great White Throne, at which the lost, small and great, are assigned their punishment for having spurned God’s offers of mercy. The text says, “The dead were judged according to what they had done as recorded in the books.”
Salvation is given freely as a gift. God gives eternal life to as many as repent and believe the gospel. Nobody can earn it. Read John 3:16–21. But those who refuse to repent and believe will be judged according to what they did in life, and nothing that they did while alive can absolve them. Their prospects are terrifying.