Advertisement
esraa_syam

Untitled

Oct 22nd, 2022
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.14 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. #define nl "\n"
  3. #define fi first
  4. #define se second
  5. #define pi 3.14159
  6. #define ll long long
  7. #define odd(a) (a&1)
  8. #define even(a) !(a&1)
  9. #define Mod 1'000'000'007
  10. #define INF 2'000'000'000
  11. #define sz(x) int(x.size())
  12. #define charToInt(s) (s - '0')
  13. #define ull unsigned long long
  14. #define all(s) s.begin(), s.end()
  15. #define rall(v) v.rbegin() , v.rend()
  16. #define fixed(n) fixed << setprecision(n)
  17. #define Num_of_Digits(n) ((int)log10(n) + 1)
  18. #define to_decimal(bin) stoll(bin, nullptr, 2)
  19. #define Ceil(n, m) (((n) / (m)) + ((n) % (m) ? 1 : 0))
  20. #define Floor(n, m) (((n) / (m)) - ((n) % (m) ? 0 : 1))
  21. #define Upper(s) transform(all(s), s.begin(), ::toupper);
  22. #define Lower(s) transform(all(s), s.begin(), ::tolower);
  23. #define cout_map(mp) for(auto& [f, s] : mp) cout << f << " " << s << "\n";
  24. // ----- bits-------
  25. #define pcnt(n) __builtin_popcount(n)
  26. #define pcntll(n) __builtin_popcountll(n)
  27. #define clz(n) __builtin_clz(n) // <---100
  28. #define clzll(n) __builtin_clzll(n)
  29. #define ctz(n) __builtin_ctz(n) // 0001---->
  30. #define ctzll(n) __builtin_ctzll(n)
  31.  
  32. using namespace std;
  33.  
  34. template < typename T = int > istream& operator >> (istream &in, vector < T > & v){
  35. for(auto & x : v) in >> x;
  36. return in;
  37. }
  38.  
  39. template < typename T = int > ostream& operator << (ostream &out, const vector < T > & v){
  40. for(const T & x : v) out << x << " ";
  41. return out;
  42. }
  43.  
  44. void esraa()
  45. {
  46. ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
  47. #ifndef ONLINE_JUDGE
  48. freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout);
  49. #endif
  50. }
  51. void solve(){
  52. ll n;
  53. cin >> n;
  54. stack < ll > st;
  55. ll num;
  56. cin >> num;
  57. st.push(num);
  58. ll count = 1 , maxi = 0;
  59. for(int i = 1 ; i < n ; i++){
  60. ll x;
  61. cin >> x;
  62. if(st.top() != x){
  63. st.push(x);
  64. count++;
  65. }else{
  66. maxi = max(maxi , count);
  67. count = 1;
  68. st.push(x);
  69. }
  70.  
  71. }
  72. cout << max(maxi , count) << nl;
  73. }
  74. int main()
  75. {
  76. esraa();
  77. int t = 1;
  78. //cin >> t;
  79. while(t--)
  80. solve();
  81. return 0;
  82. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement