2 solutions
-
3
ysh牛逼
```cpp #include<bits/stdc++.h> using namespace std; const int N=1e5+10; struct yshnb{ int begin; int end; }dsjnb[N]; bool cmp(yshnb &a,yshnb&b) { return a.end < b.end; } int main() { int n; cin>>n; int index=0; while(n--) { int l,r; cin>>l>>r; dsjnb[index++]={l,r}; } sort(dsjnb,dsjnb+index,cmp); int last_end=dsjnb[0].end; int cnt=1; for(int i=1;i<index;i++) { int p=dsjnb[i].begin; int q=dsjnb[i].end; if(last_end<=p) { cnt++; last_end=q; } } cout<<cnt<<"\n"; return 0; }
Information
- ID
- 2
- Time
- 1000ms
- Memory
- 256MiB
- Difficulty
- 2
- Tags
- # Submissions
- 37
- Accepted
- 18
- Uploaded By