fork(1) download
  1. #include <iostream>
  2. #include <vector>
  3. #include <iterator>
  4. #include <algorithm>
  5.  
  6. using namespace std;
  7.  
  8. int main() {
  9. istream_iterator<int> eos;
  10. istream_iterator<int> iit (cin);
  11. vector<int> seq;
  12. copy(iit, eos, back_inserter(seq));
  13.  
  14. int len = 1, pos = 0, maxlen = 1, current_start = 0;
  15. for (int i = 1 ; i < seq.size() ; i++) {
  16. if (seq[i] > seq[i-1]) {
  17. len++;
  18. if (len > maxlen) {
  19. maxlen = len;
  20. pos = current_start;
  21. }
  22. } else {
  23. len = 1;
  24. current_start = i;
  25. }
  26. }
  27.  
  28. for (int i = pos ; i != seq.size() && (i == pos || seq[i] > seq[i-1]) ; i++) {
  29. cout << seq[i] << " ";
  30. }
  31. cout << endl;
  32. }
Success #stdin #stdout 0.01s 2816KB
stdin
2 4 1 7 4 5 0 8 65 4 2 34
stdout
0 8 65