-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path122B.cpp
More file actions
39 lines (35 loc) · 930 Bytes
/
122B.cpp
File metadata and controls
39 lines (35 loc) · 930 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define fo(i,n) for(int i = 0;i<n;i++)
#define endl '\n'
int main() {
string num;
map<string,int> freq;
cin >> num;
int l = 0;
int r;
int n = num.size();
while (l<n){
r = 0;
string parcial = "";
while(l + r < n && (num[l + r] == '4' || num[l + r] == '7')){
parcial += num[l+r];
if(!parcial.empty()) freq[parcial]++;
r++;
}
l++;
}
string maior(51,'~');
int freq_maior = -1;
for (auto& par : freq) {
if (par.second > freq_maior || (par.second == freq_maior && par.first < maior)) {
maior = par.first;
freq_maior = par.second;
}
}
freq_maior != -1 ? cout << maior : cout << -1;
return 0;
}