-
Notifications
You must be signed in to change notification settings - Fork 0
/
A.cpp
57 lines (37 loc) · 894 Bytes
/
A.cpp
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#include<bits/stdc++.h>
#define faster ios :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define ull unsigned long long
using namespace std;
int main()
{
faster
int n,m,x;
cin>>n>>m;
string s[n];
for(int i=0; i<n; i++)
cin>>s[i];
int aa,b,c,d,e,ss=0;
for(int i=0; i<m; i++)
{
cin>>x;
aa=0,b=0,c=0,d=0,e=0;
for(int j=0; j<n; j++)
{
if(s[j][i]=='A')
aa++;
else if(s[j][i]=='B')
b++;
else if(s[j][i]=='C')
c++;
else if(s[j][i]=='D')
d++;
else if(s[j][i]=='E')
e++;
}
int y=max(aa,max(b,max(c,max(d,e))));
ss=ss+(x*y);
}
cout<<ss<<endl;
return 0;
}