Recursive code correct but giving error on including dp array

recursive code is correct but on including dp array, segmentation fault is occuring

@akshatkaush,
Statically allocating dp is too much for 1e4*1e4, you can use dynamic allocation by using vectors.
Check here.