Assuming you are flying CX 500 which arrives at 20:30 into NRT, from my experience on the exact same flight few years ago (which arrived as per scheduled time, traveling in the back), I reach the immigration counter approximately 20:50 (due to long walk and waiting for the train, which is similar today as you take the electric walkway). Immigration and custom included probably make it 21:15 to complete, leaving you enough time to buy the discounted NEX ticket at the ticket counter and walk to the platform.
If you however missed the last NEX, you can take the following trains which heads to Ueno, take off at Nippori and change to wherever you heading within Tokyo.
21:52 Keisei-Ueno Sky Liner
22:33 Keisei-Ueno Sky Liner
22:37 Keisei-Ueno Access Express
The following non-express train goes all the way to Tokyo (But SLOW)
22:16 JR Narita Line
23:00 JR Narita Line
Also you can take the airport limousine which depart as late as 23:05 to Shinjuku
Let us know where are you actually staying then we can explain your backup plan