题目链接: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
<stringint> 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;
}

相关文章:

  • 2022-12-23
  • 2021-12-18
  • 2021-06-21
  • 2022-12-23
  • 2018-12-01
  • 2022-01-22
  • 2022-02-04
猜你喜欢
  • 2022-12-23
  • 2021-12-09
  • 2021-10-20
  • 2021-12-20
  • 2022-12-23
  • 2022-12-23
  • 2021-11-21
相关资源
相似解决方案