fork(1) 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. } else {
  18. i = n;
  19. }
  20. if (i == n) {
  21.  
  22. while (currentEl < lowVal ) {
  23. cout << currentEl << " ";
  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 5304KB
stdin
4
16 256 199 74
stdout
256 199 74 0