fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main() {
  5. int n;
  6. cin >> n;
  7.  
  8. vector<int> a(n);
  9. for (int i = 0; i < n; i++)
  10. cin >> a[i];
  11.  
  12. int first = INT_MAX;
  13. int second = INT_MAX;
  14.  
  15. for (int x : a) {
  16. if (x <= first) {
  17. first = x;
  18. }
  19. else if (x <= second) {
  20. second = x;
  21. }
  22. else {
  23. cout << true;
  24. return 0;
  25. }
  26. }
  27.  
  28. cout << false;
  29. return 0;
  30. }
Success #stdin #stdout 0.01s 5324KB
stdin
8
18 5 4 3 2 1 8 10
stdout
1