The code is giving Runtime error

The code is giving runtime error on this problem of cses problem set while the commented code got AC( at bottom of my code ) please tell what is the issue with my code !!

hello @aryan_007 please share your code so that i can see the mistake and rectify it .

Code : https://ideone.com/qP2xv7

Problem stmt : https://cses.fi/problemset/task/1636

The commented code below my code is working fine but it also uses same vector size , still why mine code is giving Runtime Error !!

hey @aryan_007 i have seen you code and the commented code as well .
do you know that bottom up is more fast then the top down approach .
The code which you have commented under your code is bottom up and i have seen that your code is giving TLE in 6 cases .

Sir, TLE hoti to maan bhi leta but it is giving Runtime Error :frowning:

And how are we able to make vector of 1e8 :open_mouth:

your logic is perfectly working fine for smaller cases but giving tle on bigger cases because of the constraints .
there is same question on hackerblocks but because the constraints are not so big there then this approach of yours will work there.

dear @aryan_007 i have tried submitting your questrion there only and it is giving TLE only.
could you please share the screenshot for run time error .

image

Sir, Its Runtime error :frowning:

please see if you are submitting the same code which you have shared here ?

yes sir ,excatly same code

But still sir how is 1e8 vector possible ??

I heard that 1e6 - 1e7 is max limit !! so, how he made 1e8 vector ??

hey @aryan_007 i think you are getting confused he has declared mod as 1e9+7.
he has taken the vector size for forming the dp according to the target which he is taking input .
and even in the constraint 1e6 is the maximum value then there is no need to form the vector of 1e9 .

hey second number is not the size of the array or vector it is the sum or target we can say .
why are you combining as a single when we are making a 2d array

So, sir can be make a dp[100][1000000] of this size ??