fork download
  1. #include <iostream>
  2. using namespace std;
  3. int main() {
  4. int N;
  5. cin >> N;
  6. int nr;
  7. cin >> nr;
  8. int i = 1, mountain = 1, ascendent = 0, descendent = 0, ascendent2 = 0;
  9. while (i < N) {
  10. int new_nr;
  11. cin >> new_nr;
  12. if (new_nr == nr) {
  13. mountain = 0;
  14. }
  15. if (new_nr > nr && descendent == 0) {
  16. nr = new_nr;
  17. ++ascendent;
  18. }
  19. if (new_nr < nr && descendent == 0) {
  20. nr = new_nr;
  21. ++descendent;
  22. }
  23. if (new_nr > nr && descendent != 0) {
  24. ++ascendent2;
  25. }
  26. if (new_nr < nr && descendent != 0) {
  27. nr = new_nr;
  28. ++descendent;
  29. }
  30. ++i;
  31. }
  32. if (mountain == 0 || ascendent2 != 0 || descendent == 0 || ascendent == 0) {
  33. cout << 0;
  34. } else {
  35. cout << 1;
  36. }
  37. return 0;
  38. }
Success #stdin #stdout 0s 5348KB
stdin
11
0 1 2 3 4 5 6 7 8 9 0
stdout
1