TopH Decent Arrays Solution

Solve  in C:

#include<bits/stdc++.h>
using namespace std;
int main()
{
    int i,j,t,f=0,ar[1001],n,a[1001];
    while(cin>>n)
    {
        for(i=0; i<n; i++)
        {
            cin>>ar[i];

        }
        for(i=1; i<n; i++)
        {
            if(ar[i-1]>ar[i])
            {
              f=1;
              break;
            }


        }
        if(f==1)
            cout<<"No"<<endl;
        else
            cout<<"Yes"<<endl;
            f=0;
    }
}

No comments

Most View Post

Recent post

Codeforces Round 971 (Div. 4) 2009C. The Legend of Freya the Frog Solution

  Problem Link    https://codeforces.com/contest/2009/problem/C S olution in C++: /// Author : AH_Tonmoy #include < bits / stdc ++. h ...

Powered by Blogger.