-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path1201A.cpp
More file actions
32 lines (26 loc) · 689 Bytes
/
Copy path1201A.cpp
File metadata and controls
32 lines (26 loc) · 689 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
int freqans[26];
int main() {
int n, m;
scanf("%d %d", &n, &m);
string ans[n];
int scores[m];
for (int i = 0; i < n; i++)
cin >> ans[i];
for (int i = 0; i < m; i++)
cin >> scores[i];
LL anss = 0;
for (int i = 0; i < m; i++) {
int tempmax = INT_MIN;
memset(freqans, 0, sizeof(freqans));
for (int j = 0; j < n; j++) {
freqans[ans[j][i] - 'A']++;
if (freqans[ans[j][i] - 'A'] > tempmax)
tempmax = freqans[ans[j][i] - 'A'];
}
anss += tempmax * scores[i];
}
printf("%I64d\n", anss);
}