Advertisement
Falak_Ahmed_Shakib

temp 1

Jul 19th, 2019
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<string.h>
  3. int main()
  4. {
  5. int t,kase=1;
  6. scanf("%d",&t);
  7. while(t--)
  8. {
  9. int flag=0,n,i,cnt=0;
  10. scanf("%d",&n);
  11. int ara[n+1];
  12. for(i=0;i<n;i++)
  13. {
  14. scanf("%d",&ara[i]);
  15. }
  16.  
  17.  
  18. if(ara[0]>=ara[1])
  19.  
  20. for(i=0;i<n-1;i++)
  21. {
  22. if(ara[i]>ara[i+1])
  23. {
  24. cnt++;
  25. if(cnt==n-1)flag=1;
  26.  
  27. }
  28. }
  29. else
  30. for(i=0,cnt=0;i<n-1;i++)
  31. {
  32. if(ara[i]<ara[i+1])
  33. {
  34. cnt++;
  35. if(cnt==n-1)flag=1;
  36.  
  37. }
  38. }
  39. if(flag==1)
  40. {
  41. printf("YES\n");
  42. }
  43. else printf("NO\n");
  44.  
  45. }
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement