@rawr links to Why are these numbers not equal? , which explains the fundamental issues with floating-point computation. In this case:
print((1-0.995) - 0.005)
## [1] 4.336809e-18
Because of this, (1-0.005)*5e4 is slightly greater than 250 (to see this you have to print((1-0.005)*5e4, digits=22), because R prints a rounded representation by default) so ceiling() pushes the answer up to 251.
In this particular case it looks like you can get the desired answer by rounding (1-p) to three decimal places, ceiling(N*round(1-p,3))  — but you should definitely read the linked answer and think about whether this solution will be robust for all of your needs.