-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1339.cpp
More file actions
39 lines (32 loc) · 752 Bytes
/
1339.cpp
File metadata and controls
39 lines (32 loc) · 752 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;
int res;
int alpha[26];
bool comp(string a, string b){
return a.length() > b.length();
}
int main(void) {
ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
int N;
cin >> N;
vector<string> v(N);
for(int i = 0; i < N; i++)
cin >> v[i];
for(int i = 0; i < v.size(); i++){
int pow = 1;
for(int j = v[i].size() - 1; j >= 0; j--){
int val = v[i][j] - 'A';
alpha[val] += pow;
pow *= 10;
}
}
sort(alpha, alpha + 26);
int num = 9;
for(int i = 25; i >= 0; i--){
if(!alpha[i]) break;
res += (alpha[i] * num);
num--;
}
cout << res << '\n';
return 0;
}