Skip to content

Instantly share code, notes, and snippets.

@grim-yawn
Created December 22, 2016 21:28
Show Gist options
  • Save grim-yawn/618f4c93ea68cd5529c839104f5352b6 to your computer and use it in GitHub Desktop.
Save grim-yawn/618f4c93ea68cd5529c839104f5352b6 to your computer and use it in GitHub Desktop.
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int letter_to_index(char letter, char first_letter = 'a') {
return letter - first_letter;
}
int main() {
const int alphabet_size = 26;
vector<int> letters_height(alphabet_size);
for (int & el: letters_height) {
cin >> el;
}
string word;
cin >> word;
const char letter_with_max_height = *max_element(word.begin(), word.end(),
[letters_height](char a, char b) {
return letters_height[letter_to_index(a)] <
letters_height[letter_to_index(b)];
});
const int max_height = letters_height[letter_to_index(letter_with_max_height)];
cout << word.size() * max_height;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment