Advertisement
islomiddin

479_B

May 6th, 2018
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.54 KB | None | 0 0
  1. #include <iostream>
  2. #include <algorithm>
  3. using namespace std;
  4. int main() {
  5.     int n;
  6.     string s;
  7.     cin >> n >> s;
  8.     int max = 0;
  9.     string ans = "";
  10.     for (int i = 0; i < n; i += 2) {
  11.         string tmp = s.substr(i, 2);
  12.         int cnt = 0;
  13.         for (int i = 0; i < n - 1; ++i) {
  14.             string str = s.substr(i, 2);
  15.             if (tmp == str) {
  16.                 ++cnt;
  17.             }
  18.         }
  19.         if (cnt > max) {
  20.             max = cnt;
  21.             ans = tmp;
  22.         }
  23.     }
  24.     cout << ans << endl;
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement