代码实现:
#include<stdio.h>
#include<stdlib.h>
int main()
{
int N, M, *score, *answer;
scanf("%d %d", &N, &M);
score = (int*)malloc(sizeof(int)*M);
answer = (int*)malloc(sizeof(int)*M);
for (int i = 0; i < M; i++)scanf("%d", &score[i]);
for (int i = 0; i < M; i++)scanf("%d", &answer[i]);
for (int i = 0; i < N; i++)
{
int sum = 0;
for (int j = 0; j < M; j++)
{
int choice;
scanf("%d", &choice);
if (choice == answer[j])sum += score[j];
}
printf("%d\n", sum);
}
return 0;
}