#include <stdio.h>
#include <string.h>
struct word
{
char name[101];
int n;
};
struct word a[100000];
struct word b[100000];
int main(void){
int i, j, n, m, temp=0;
scanf("%d %d", &n, &m);
for(i=0; i<n; i++){
scanf("%s %d", a[i].name, &a[i].n);
}
for(i=0; i<m; i++){
scanf("%s", b[i].name);
b[i].n = 0;
for(j=0; j<n; j++){
if(strcmp(b[i].name, a[j].name) == 0){
b[i].n += a[j].n;
}
}
printf("%d\n", b[i].n);
}
return 0;
}
To embed this project on your website, copy the following code and paste it into your website's HTML: