Decent Arrays - Easy Problems - Solution to Toph.co Online Judge Problem

Decent Arrays

Limits 1s, 512 MB

Given N numbers determine if they are in ascending order.

Input

The first line of the input will contain N (0 < N < 100).
The following line will contain N integers, each between 1 and 1000.

Output

Print “Yes” if the numbers were in ascending order, otherwise “No”.

#include<stdio.h>

int main()
{
   int n,i,flag=0;

    scanf("%d", &n);
     int a[n];
   for(i=0;i<n;i++)
   {
       scanf("%d",&a[i]);

   }
    for(i=0;i<n-1;i++)
    {
        if(a[i]>a[i+1])
        {
            flag=1;
            break;
        }
    }
   if(flag==1)
    printf("No");
   else
    printf("Yes");
}