Advertisement
Guest User

Untitled

a guest
Jan 7th, 2024
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.75 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. void solve() {
  6.     int n;
  7.     cin >> n;
  8.     vector<pair<int, int>> st;
  9.     for (int i = 0; i < n; i++) {
  10.         int x;
  11.         cin >> x;
  12.         if (st.empty() || st.back().first != x) {
  13.             st.emplace_back(x, 1);
  14.             continue;
  15.         }
  16.         auto [_, cnt] = st.back();
  17.         st.pop_back();
  18.         st.emplace_back(x, cnt + 1);
  19.     }
  20.     int ans = 0;
  21.     for (auto [x, cnt] : st) {
  22.         if (x == 7) {
  23.             ans = max(ans, cnt);
  24.         }
  25.     }
  26.     cout << ans << '\n';
  27. }
  28.  
  29. int main() {
  30.     ios_base::sync_with_stdio(0);
  31.     cin.tie(0);
  32.    
  33.     int tc = 1;
  34.     cin >> tc;
  35.     for (int t = 1; t <= tc; t++) {
  36.         solve();
  37.     }
  38.    
  39.     return 0;
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement