bogolyubskiyalexey

Untitled

Sep 19th, 2020
757
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <map>
  2. #include <vector>
  3. #include <string>
  4.  
  5. std::map<std::string, int> final_standings(
  6.     const std::vector<std::map<std::string, int>>& contests
  7. ) {
  8.     std::map<std::string, int> result;
  9.     for (const auto& contest : contests) {
  10.         for (const auto& studentResult : contest) {
  11.             auto [it, inserted] = result.try_emplace(
  12.                 studentResult.first,
  13.                 studentResult.second);
  14.             if (!inserted) {
  15.                 it->second = std::max(it->second, studentResult.second);
  16.             }
  17.         }
  18.     }
  19.     return result;
  20. }
RAW Paste Data