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 925 (Div. 3) 1931D. Divisible Pairs Solution

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

Powered by Blogger.