Advertisement
dmkozyrev

solve.cpp

May 14th, 2018
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.24 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. typedef long long Int;
  4.  
  5. Int solve(Int changes, const std::string& s) {
  6.     std::vector<Int> count(256, 0);
  7.     for (auto& it : s) {
  8.         count[it]++;
  9.     }
  10.     Int max = *std::max_element(count.begin(), count.end());
  11.     // сколько замен будет сделано для получения максимального результата?
  12.     if (changes < (Int)s.size() - max) {
  13.         return max + changes;
  14.     } else {
  15.         return (Int)s.size();
  16.     }
  17. }
  18.  
  19.  
  20. int main() {
  21.     std::ios_base::sync_with_stdio(false); std::cin.tie(0); std::cout.tie(0);
  22.    
  23.     Int changes;
  24.     std::cin >> changes;
  25.    
  26.     std::string a, b, c;
  27.     std::cin >> a >> b >> c;
  28.    
  29.     Int res1 = solve(changes, a);
  30.     Int res2 = solve(changes, b);
  31.     Int res3 = solve(changes, c);
  32.    
  33.     std::map<Int, Int> count;
  34.    
  35.     count[res1]++;
  36.     count[res2]++;
  37.     count[res3]++;
  38.    
  39.     auto max = std::max({res1, res2, res3});
  40.    
  41.     if (count[max] >= 2) {
  42.         std::cout << "Draw";
  43.         return 0;
  44.     }
  45.    
  46.     std::map<Int, std::string> user;
  47.    
  48.     user[res1] = "Kuro";
  49.     user[res2] = "Shiro";
  50.     user[res3] = "Katie";
  51.    
  52.     std::cout << user[max];
  53.    
  54.     return 0;
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement