POJ2403 Hay Points

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

posted on 2009-09-12 15:07  Phinecos(洞庭散人)  阅读(654)  评论(0编辑  收藏  举报

导航