Hii…
I am trying to solve this question…
https://codeforces.com/problemset/problem/1381/B 2
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 1
Thanks.