SHARE
TWEET

codeforce - pillars

jakaria_hossain Jul 23rd, 2019 55 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. int main()
  4. {
  5.     int n,i;
  6.     cin>>n;
  7.     int ara[n+1],m=0;
  8.     for(i=0; i<n; i++)
  9.     {
  10.         cin>>ara[i];
  11.     }
  12.     for(i=0; i<n; i++)
  13.         if(ara[i]>ara[m])
  14.             m=i;
  15.     for(i=m; i>0; i--)
  16.     {
  17.         if(ara[i]<ara[i-1])
  18.         {
  19.             cout<<"no"<<endl;
  20.             return 0;
  21.         }
  22.     }
  23.     for(i=m; i<n-1; i++)
  24.     {
  25.         if(ara[i]<ara[i+1])
  26.         {
  27.             cout<<"no"<<endl;
  28.             return 0;
  29.         }
  30.     }
  31.     cout<<"yes"<<endl;
  32. }
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