SHARE
TWEET

Untitled

a guest Jan 19th, 2019 69 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>;
  2. #include <math.h>;
  3. #include <algorithm>;
  4. #include <stdio.h>;
  5. using namespace std;
  6. int f[1000001];
  7. int g[1000001];
  8. int main()
  9. {
  10.     //freopen("rqp.in","r",stdin);
  11.     //freopen("rqp.out","w",stdout);
  12.  
  13.     long long a,b,d,e,z,j,i,x;
  14.     b=0;
  15.     cin>>a;
  16.     for (i=1; i<=a; i++)
  17.     {
  18.         cin>>f[i];
  19.         if (f[i]==1) x=i;
  20.     }
  21.     for (j=x; j<=a; j++)
  22.     for (i=x; i>=1; i--)
  23.        
  24.         {
  25.             for (z=i; z<=j; z++)
  26.                 g[z]=f[z];
  27.             sort(g+i,g+j);
  28.             if (g[j]==1+j-i) b++;
  29.         }
  30.        
  31.         cout<<b;
  32.  
  33.     return 0;
  34. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top