题意:一个班级有n个学生,在进行一场共m道题的考试。每道题只有一个正确选项,提供ABCDE五个选项。已知所有学生的选择和每道题的分值,问如何拟定正确答案可以使全班的总分最高?
统计每道题ABCDE的最大值即可。
#include <cstdio>
#include <algorithm>
#include <iostream>
using namespace std;
#define MAX_N 1010
#define ll long long
int n, m;
int ans[MAX_N][120], score[MAX_N];
ll totalscore;
int main()
{
scanf("%d %d", &n, &m);
for(int i = 1;i <= n;i++)
{
getchar();
for(int j = 1;j <= m;j++)
{
char c;
scanf("%c", &c);
//cout << c;
ans[j][c]++;
//cout << "ans = " << ans[j][c] << endl;
}
}
for(int i = 1;i <= m;i++)
{
scanf("%d", &score[i]);
//cout << score[i];
}
for(int i = 1;i <= m;i++)
{
int temp;
temp = max(max(max(max(ans[i]['A'], ans[i]['B']), ans[i]['C']), ans[i]['D']), ans[i]['E']);
totalscore += temp*score[i];
}
printf("%lld\n", totalscore);
return 0;
}