I can’t understand what question wants to say.

help me to understand this problem.

You have to output as minimum number of separate nested dolls as possible like In first test case

3

20 30 40 50 30 40

You see all the dolls can be fit in one doll that is {20,30} doll in {30,40} in {40,50}. so ans is 1 doll. Similarly in second test case

4

20 30 10 10 30 20 40 50

{10,10} in {20,30} and{30,20} in {40,50} (or the {20,30} doll can be fitted in {40,50} and {30,20} separate)

so there need to be 2 different nested dolls. so ans is 2

In third test case no dolls can be fitted inside. So ans is 3

In fourth test case {10,10} in {20,30} in {40,50} and {39,51} is separate. so ans is 2.

how LIS will solve this problem ? I can’t figure out/

Sort by height and keep extracting lis until you have no element left the number of times you extract is the ans I think as you would want to put as many dolls as possible in each nested doll

This code is showing segmentation error but it is not showing error in my compiler

can anyone pls check where there is mistake

#include <bits/stdc++.h>

using namespace std;

void solve();

int main(){

int T;

cin>>T;

while(T–){

solve();

}

```
return 0;
```

}

void solve(){

int n,a[10005];

cin>>n;

int p;

p=n;

for(int i=0;i<2*n;i++){
cin>>a[i];
}
int x=0,y=0;
x=a[0];
y=a[1];
for(int i=2;i<2*n-1;i++){

if(x<a[i] && y<a[i+1]) {

x = a[i];

y = a[i + 1];

p–;

}

else if(x>a[i]&& y>a[i+1]){

p–;

}

i++;

}

cout<<p<<endl;

}