Loading Similar Posts
bool sss(pi &A,pi &B){
if(A.ff == B.ff)return A.ss < B.ss;
return A.ff < B.ff;
}
void solve(){
int n;cin>>n;
vi A(n),B(n);
for(int i = 0;i<n;i++)cin>>A[i];
for(int i = 0;i<n;i++)cin>>B[i];
vpi tt(n);
for(int i = 0;i<n;i++)tt[i] = {A[i],B[i]};
sort(tt.begin(),tt.end(),sss);
int ans = 0;
int prev = -1;
for(int i = 0;i<n;i++){
if(i == 0){
ans++;
prev = tt[0].ss;
continue;
}
if(prev <= tt[i].ff){
ans++;
prev = tt[i].ss;
}
}
cout<<ans<<'\n';
}