Advertisement
Guest User

Untitled

a guest
Feb 17th, 2020
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.45 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. int main()
  4. {
  5.     std::ios_base::sync_with_stdio(0);
  6.     std::cin.tie(0);
  7.  
  8.     std::string s;
  9.     std::cin >> s;
  10.  
  11.     std::vector<int> v;
  12.  
  13.     int qtd = 1;
  14.     char last = '$';
  15.     for (const char &c : s)
  16.     {
  17.         if (c == last)
  18.         {
  19.             qtd += 1;
  20.         }
  21.         else
  22.         {
  23.             v.push_back(qtd);
  24.             qtd = 1;
  25.             last = c;
  26.         }
  27.     }
  28.     v.push_back(qtd);
  29.  
  30.     std::sort(v.rbegin(), v.rend());
  31.  
  32.     std::cout << (1LL * v[0] * v[1]) << std::endl;
  33.  
  34.     return 0;
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement