Untitled

mail@pastecode.io avatar
unknown
plain_text
a month ago
648 B
1
Indexable
Never
#include <iostream>

using namespace std;

int main() {
  int n;
  cin >> n;

  int arr[n];
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
  }

  int maxLength = 1;
  int currentLength = 1;
  int start = 0;

  for (int i = 1; i < n; i++) {
    if (arr[i] >= arr[i - 1]) {
      currentLength++;
    } else {
      currentLength = 1;
    }

    if (currentLength > maxLength) {
      maxLength = currentLength;
      start = i - maxLength + 1;
    }
  }

  cout << "Day con tang dai nhat la: ";
  for (int i = start; i < start + maxLength; i++) {
    cout << arr[i] << " ";
  }
  cout << endl;

  return 0;
}
Leave a Comment