Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <map>
- #include <vector>
- #include <string>
- std::map<std::string, int> final_standings(
- const std::vector<std::map<std::string, int>>& contests
- ) {
- std::map<std::string, int> result;
- for (const auto& contest : contests) {
- for (const auto& studentResult : contest) {
- auto [it, inserted] = result.try_emplace(
- studentResult.first,
- studentResult.second);
- if (!inserted) {
- it->second = std::max(it->second, studentResult.second);
- }
- }
- }
- return result;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement