Getting Tle In this question

Hii…
I am trying to solve this question…
https://codeforces.com/problemset/problem/1381/B

My logic is… In main array for a number ‘x’ if all the number which comes after x will be in same array…
So in this fashion i have collected all the block of numbers which will go in same array…

Now after collecting all the numbers in vector , problem comes down to check …if the subset sum of this vector is equal to ‘n’ or not…
I have written DP code for that…
But don’t know why it is getting tle…
Please check this .
https://codeforces.com/contest/1381/submission/100868798

Thanks.

Hello @ashishnnnnn please wait i need to understand question and then i can tell you.

i think your intuition is correct .
you can see the video here:
https://www.google.com/search?biw=994&bih=736&tbm=vid&sxsrf=ALeKk034iGYd1daTgaeKzK2ulGup3txGFA%3A1607660491982&ei=y_PSX4CsO4Ca4-EPm-C6oAc&q=Codeforces+Round+%23658+(Div.+1)+unmerge&oq=Codeforces+Round+%23658+(Div.+1)+unmerge&gs_l=psy-ab.3...22905.26021.0.26679.8.8.0.0.0.0.422.1032.0j4j4-1.5.0....0...1c.1.64.psy-ab..3.0.0....0.lvo4jhw-iYM

Hii…
I know my intutuion is correct…
I want to know… where i am doing wrong in code… So it is giving TLE…
If you can help…
Thanks

hello @ashishnnnnn i got your intuition but i am not able to find why it is not working.
incase you are in hurry you can raise the doubt again.
i need time to think about this and see about the error.

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.