Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <algorithm>
- using namespace std;
- int main()
- {
- int n;
- int brojac=1;
- cin>>n;
- vector<pair<int, int>>v;
- for(int i=0; i<n; i++){
- int a;
- int b;
- cin>>a>>b;
- v.push_back(make_pair(b, a));
- }
- sort(v.begin(), v.end());
- int nd=v[0].first;
- int start=v[0].second;
- for(int j=1; j<n; j++){
- int tnd=v[j].first;
- int tstart=v[j].second;
- if(tstart>=nd){
- brojac+=1;
- nd=tnd;
- start=tstart;
- }
- }
- cout<<brojac;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement