// Run time: 0.000
#include <stdio.h>
#include <string.h>
typedef struct {
char word[17];
int pay;
} Work;
int main()
{
char str[25]; // dictionary string
char tmp[100]; // job descriptions string
int m, n;
int i, j; // loop counting
int sum;
while (scanf("%d%d", &m, &n) == 2)
{
Work work[m];
getchar();
for ( i = 0; i < m; i++)
{
gets(str);
sscanf(str, "%s %d", work[i].word, &work[i].pay);
}
for ( i = 0; i < n; i++)
{
sum = 0;
while (true)
{
scanf("%s", tmp);
if (tmp[0] == '.')
break;
for ( j = 0; j < m; j++)
if (!strcmp(tmp, work[j].word))
sum += work[j].pay;
}
printf("%d\n", sum);
}
}
}
沒有留言:
張貼留言