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. while (i < n) {
  12. cin >> currentEl;
  13. if (currentEl > highVal && i < n) {
  14. highVal = currentEl;
  15. ++posHighVal;
  16. ++i;
  17. //cout << currentEl <<"<-A ";
  18. } else {
  19. i = n;
  20. }
  21. if (i == n) {
  22. while (currentEl < lowVal && currentEl < highVal) {
  23. cout << currentEl <<"<-B ";
  24. lowVal = currentEl;
  25. ++posHighVal;
  26. cin >> currentEl;
  27. }
  28. }
  29. }
  30. if (i == n && posHighVal == n ) {
  31. cout << "1";
  32. } else {
  33. cout << "0";
  34. }
  35. return 0;
  36. }
Success #stdin #stdout 0.01s 5288KB
stdin
9
1 2 3 4 5 6 7 4 1 
stdout
Standard output is empty