Skip to content

Commit

Permalink
단어 수학
Browse files Browse the repository at this point in the history
  • Loading branch information
yewon-yw authored Jun 2, 2022
1 parent 0843e87 commit 1119b94
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions greedy_algorithm/1339.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
int alpha[26];

int main() {
int n, sum = 0, num = 9;
cin >> n;
string str;
for (int i = 0; i < n; i++) {
cin >> str;
int digit = 1;
for (int j = str.length() - 1; j >= 0; j--) {
alpha[str[j]-'A'] += digit;
digit *= 10;
}
}
sort(alpha, alpha + 26, greater<int>());
for (int i = 0; i < 26; i++) {
sum += alpha[i] * num;
num--;
}
cout << sum;
}

0 comments on commit 1119b94

Please sign in to comment.