提交时间:2024-07-17 11:08:30
运行 ID: 156391
#include<iostream> #include<algorithm> using namespace std; struct stu{ int start, end; bool is_in; void input(){ cin >> start >> end; is_in = false; } bool operator == (const stu & o) const{ return start < o.end || end < o.start; } bool operator != (const stu & o) const{ return !(start < o.end || end < o.start); } bool operator < (const stu & o) const{ return end < o.end; } }; stu ary[100010]; int main(){ int n; cin >> n; for(int i = 0; i < n; i++){ ary[i].input(); } sort(ary, ary + n); int cnt = 0; int now = 0; for(int i = 0; i < n; i++){ if(ary[i].start >= now){ cnt++; now = ary[i].end; } } cout << cnt; return 0; }