Advertisement
a53

sir_zigzag

a53
May 1st, 2017
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4. int n,a,ant,sw;
  5. int main()
  6. {
  7. cin>>n;
  8. cin>>a;
  9. ant=a;
  10. cin>>a;
  11. if(a>ant)
  12. sw=1;
  13. if(a<ant)
  14. sw=0;
  15. if(a==ant)
  16. {
  17. cout<<"NU";
  18. return 0;
  19. }
  20. ant=a;
  21. for(int i=3;i<=n;i++)
  22. {
  23. cin>>a;
  24. if(sw&&a>ant)
  25. {
  26. cout<<"NU";
  27. return 0;
  28. }
  29. if(!sw&&a<ant)
  30. {
  31. cout<<"NU";
  32. return 0;
  33. }
  34. if(a==ant)
  35. {
  36. cout<<"NU";
  37. return 0;
  38. }
  39. sw=!sw;
  40. ant=a;
  41. }
  42. cout<<"DA";
  43. return 0;
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement