#include <iostream>
#include <map>
#include <string>
int main() {
std::multimap<std::string, int> studentScores;
// Inserting elements
studentScores.insert({"Alice", 85});
studentScores.insert({"Bob", 90});
studentScores.insert({"Alice", 92}); // Another score for Alice
studentScores.insert({"Charlie", 88});
studentScores.insert({"Bob", 95}); // Another score for Bob
// Iterating through the multimap
for (const auto& pair : studentScores) {
std::cout << pair.first << ": " << pair.second << std::endl;
}
// Counting entries for a specific key
std::string name = "Alice";
std::cout << "Number of scores for " << name << ": "
<< studentScores.count(name) << std::endl;
// Finding all scores for a specific student
auto range = studentScores.equal_range(name);
std::cout << name << "'s scores: ";
for (auto it = range.first; it != range.second; ++it) {
std::cout << it->second << " ";
}
std::cout << std::endl;
// Size of the multimap
std::cout << "Total number of scores: " << studentScores.size() << std::endl;
return 0;
}