voidmerge(vector<PII> &qqj) { vector<PII> ans; sort(qqj.begin(), qqj.end()); int st = -2e9, ed = -2e9; for (auto it : qqj) { if (it.first > ed) { if (st != -2e9) ans.push_back({st, ed}); st = it.first, ed = it.second; } else ed = max(ed, it.second); } if (st != -2e9) ans.push_back({st, ed}); qqj = ans; }
intmain() { cin >> n; while ( n -- ) { int l, r; cin >> l >> r; qj.push_back({l, r}); } merge(qj); cout << qj.size() << endl; return0; }