intsolve(int n, vector<int> A, vector<int> B){ vector<pair<int,int>> S; for(int i = 0; i < n; i++) S.push_back({A[i],B[i]}); sort(begin(S), end(S)); int res = 0, ma = 0; for(int i = 0; i < n; i++) { auto [s,e] = S[i]; if(s > ma) { res += 1; ma = e; } else ma = min(ma,e); } return res; }