How much pre computation in a problem is ok?

https://www.codechef.com/viewsolution/46811054
In this solution here, he precomputed value in a 1001 * 1001 matrix. That actually sounds a lot… So I wanted to know how much is ok?
Thank you in advance!