Advertisement
knakul853

Untitled

Nov 22nd, 2020
592
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.39 KB | None | 0 0
  1.  vector<pair<int,int>>p;
  2.    
  3.     for(int i=0; i<n; i++){
  4.         p.push_back({end[i], i});
  5.     }
  6.     sort(p.begin(), p.end());
  7.    
  8.     int ans = 1;
  9.     int mx = p[0].first;
  10.    
  11.     cout<<p[0].second+1<<" ";
  12.    
  13.     for(int i=1; i<n; i++){
  14.        
  15.         if(start[p[i].second] > mx){
  16.             cout<<p[i].second+1<<" ";
  17.             mx =  p[i].first;
  18.         }
  19.        
  20.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement