题目链接:http://acm.pku.edu.cn/JudgeOnline/problem?id=2403
- #include <map>
- #include <iostream>
- #include <string>
- #include <vector>
- using namespace std;
- int main()
- {
- int m,n;
- map<string, int> dict;
- cin >> m >>n;
- int i;
- string word;
- int nValue;
- for (i = 0; i < m; ++i)
- {
- cin >> word >> nValue;
- dict[word] = nValue;
- }
- for (i = 0; i < n; ++i)
- {
- int sum = 0;
- while (cin >> word && word != ".")
- {
- if (dict.find(word) != dict.end())
- {
- sum += dict[word];
- }
- }
- cout << sum << endl;
- }
- return 0;
- }
转载于:https://blog.51cto.com/phinecos/368938