What's wrong with the code

The code is successfully compiling but after submitting shows wrong answer.
#include
using namespace std;
int main() {
int t;
cin>>t;
while(t–){
int n;
cin>>n;
int s[n],f[n];
for(int i=0;i<n;i++){
cin>>s[i]>>f[i];
}
int k=0;
int count=1;
for(int i=1;i<n;i++){
if(s[i]>=f[k]){
count++;
k=i;
}
}
cout<<count<<endl;
}
return 0;
}

hello @sakshi0309

the given input are not in sorted order.
so first u need to sort the input on the basis of ending the of the activities and then apply ur logic , it will work

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.