Advertisement
vlatkovski

Zborovi

Oct 8th, 2017
304
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.72 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main() {
  5.     ios::sync_with_stdio(0);
  6.     map<char, int> bm, bg;
  7.     for (int i = 1; i <= 26; ++i) {
  8.         char c;
  9.         int v;
  10.         cin >> c >> v;
  11.         bm[c] = v;
  12.         bg[toupper(c)] = v + 20;
  13.     }
  14.     string high;
  15.     int highv = -1;
  16.     int n; cin >> n;
  17.     for (int i = 0; i < n; ++i) {
  18.         string m; cin >> m;
  19.         int v = 0;
  20.         for (int i = 0; i < m.length(); ++i) {
  21.             char c = m.at(i);
  22.             v += bm[c] + bg[c]; //always in one but not the other
  23.         }
  24.         //cout << m << " " << v << endl;
  25.         if (v > highv) {
  26.             highv = v;
  27.             high = m;
  28.         }
  29.     }
  30.     cout << high;
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement