fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. const int MAX_VALUE = 1000000;
  5. int main() {
  6. int n, currentEl;
  7. cin >> n;
  8. int i = 2;
  9. int posHighVal = 0;
  10. int highVal = 0, lowVal = MAX_VALUE;
  11. int flagHighVal = 0;
  12. int flagLowVal = 1;
  13. while (flagHighVal == 0) {
  14. cin >> currentEl;
  15. if (currentEl > highVal) {
  16. highVal = currentEl;
  17. ++posHighVal;
  18. } else {
  19. flagHighVal = 1;
  20. }
  21. if (flagHighVal == 1) {
  22. flagLowVal = 1;
  23. while (currentEl < lowVal) {
  24. lowVal = currentEl;
  25. flagLowVal = 0;
  26. ++posHighVal;
  27. cin >> currentEl;
  28. }
  29. }
  30. ++i;
  31. }
  32. if (flagHighVal == 1 && posHighVal == n) {
  33. cout << "1";
  34. } else {
  35. cout << "0";
  36. }
  37. return 0;
  38. }
  39.  
Success #stdin #stdout 0s 5308KB
stdin
9
1 2 3 4 5 6 7 8 58
stdout
Standard output is empty