I have coded this crute force one but its gicing wrong output

please explain why you did so??

also its still not running


sorry that was an old link i had pasted by mistake, this is the correct one
although this approach is not as efficient as the top down dp

and as to why i have done this, it important to check if the size[n] > s because in that case you do not have to use that element at all but still call for the case of not involving this and hence return from there

another major mistake was you using cin>>size[n] in place of cin>>s[i]

hey @chemant077 if your doubt is solved, please mark it as resolved