fork download
  1. #include <bits/stdc++.h>
  2. #define ll long long
  3. using namespace std;
  4.  
  5. int a[100005];
  6. int main()
  7. {
  8. int n; cin >> n;
  9. for(int i = 0; i < n; ++i)
  10. cin >> a[i];
  11. int cnt = 1, maxi = -1e9;
  12. for(int i = 1; i < n; ++i)
  13. {
  14. if(a[i] != a[i - 1]) ++cnt;
  15. else {
  16. maxi = max(maxi, cnt);
  17. cnt = 1;
  18. }
  19. }
  20. cout << max(maxi, cnt);
  21. }
  22. //Tìm độ dài dãy tăng dài nhất
  23.  
Success #stdin #stdout 0.01s 5296KB
stdin
Standard input is empty
stdout
1