-
Notifications
You must be signed in to change notification settings - Fork 0
/
00499.cpp
40 lines (30 loc) · 880 Bytes
/
00499.cpp
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
40
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
// freopen("input.txt", "r", stdin);
// freopen("output.txt", "w", stdout);
string str;
while(getline(cin, str)){
ll f[200] = {0};
vector<pair<ll,ll>> hi;
for(ll i = 0; str[i]; i++){
if(isalpha(str[i])) ++f[str[i]- 'A'];
}
for(ll i = 'A'; i <= 'z'; i++){
if(isalpha((char) i)) hi.push_back({f[i - 'A'], i});
}
sort(hi.rbegin(), hi.rend());
ll itr = 0;
string res;
while(itr < hi.size() && hi[itr].first == hi[0].first){
res += string(1, (char)hi[itr].second);
++itr;
}
reverse(res.begin(), res.end());
cout << res << " " << hi[0].first << "\n";
}
return 0;
}