Problems - Book Shop from CSES gettng TLE

https://ide.codingblocks.com/s/413675 - Editorials Solution
https://ide.codingblocks.com/s/413676 - My Solution
Problems - Book Shop from CSES
I have Same Logic But Still I am getting TLE only I implemented Recursive DP instead of iterative .
And One More Doubt Can We Make Arrays of 1e8 size is that correct ??

Hey @yashratnani6
its 0-1 knapsack variation
Yeah testcases might be tight thats why u are getting TLE in topdown
Code it in Bottum up

Yes u can create array of that size but globally
Inside main/any function u can use 8MB space because of stack that is equivalent to two 10^6 integer array

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.

You can refer to my repository on github, where i have solved many of the CSES problems & am still updating those solutions. I would also be giving a small editorial of the general idea about the solution approach:
Link : https://github.com/MojoAlpha/CSES-Problemset