Advertisement
Josif_tepe

Untitled

Sep 29th, 2021
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.42 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. #include <algorithm>
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8.     int n;
  9.     cin>>n;
  10.     int br=1;
  11.     vector<pair<int, int>>v;
  12.     for(int i=0; i<n; i++){
  13.         int a;
  14.         cin>>a;
  15.         v.push_back(make_pair(a,i));
  16.     }
  17.     sort(v.begin(), v.end());
  18.     for(int i=0; i<n; i++){
  19.     if(v[i].second>v[i+1].second){
  20.     br+=1;
  21.     }
  22.     }
  23.  
  24.     cout<<br;
  25.  
  26.     return 0;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement