Some test cases are not passing

please help me with this code

don’t declare dp array lilke this
bool dp[n+1][sum+1];
because constraints are large
1<= n <= 1000
1<= sum <= 10^5
so make global array
bool dp[1001][100001];

check the modified Code below

No need to use long long int

Modified Code