Saleh127

CSES 2216

Apr 26th, 2021
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.44 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define ll long long
  4. #define test int t; cin>>t; for(int cs=1;cs<=t;cs++)
  5. int main()
  6. {
  7. ios_base::sync_with_stdio(0);
  8. cin.tie(0);cout.tie(0);
  9.  
  10. ll n,m=1,i,j,k;
  11.  
  12. cin>>n;
  13.  
  14. ll a[n+2]={0};
  15.  
  16. for(i=0;i<n;i++)
  17. {
  18. cin>>k;
  19. a[k]=i+1;
  20. }
  21. j=1;
  22. for(i=1;i<=n;i++)
  23. {
  24. if(m>a[i]) j++;
  25. m=a[i];
  26. }
  27. cout<<j<<endl;
  28. return 0;
  29. }
  30.  
Advertisement
Add Comment
Please, Sign In to add comment