-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathImportant-exam.cpp
63 lines (52 loc) · 1.05 KB
/
Important-exam.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
58
59
60
61
62
63
#include <bits/stdc++.h>
#define _DEBUG
#define ll long long
#define pb push_back
#define REP(i, n) for (int i = 0; i < (int)n; i++)
#define pr(i) cout << endl \
<< "...." << i << "...." << endl;
using namespace std;
void solve() {
ll n, m;
cin >> n >> m;
vector<int> points(m);
vector<int> count(4);
vector<string> li(n);
map<char,int> answers;
REP(i,n) { cin>>li[i]; }
REP(i,m) { cin>>points[i]; }
int countIndex=0;
int sum=0;
REP(i, m) {
countIndex=1;
answers.clear();
REP(j,n) {
if(answers.find(li[j][i])==answers.end())
answers[li[j][i]]=1;
else {
answers[li[j][i]]++;
countIndex = max(answers[li[j][i]],countIndex);
}
}
sum+= points[i]*countIndex;
}
cout<<sum<<"\n";
}
int main() {
#ifdef _DEBUG
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
int tt = clock();
#endif
int no_of_test_cases;
// cin >> no_of_test_cases;
no_of_test_cases = 1;
while (no_of_test_cases--) {
solve();
}
#ifdef _DEBUG
cerr << "TIME = " << clock() - tt << endl;
tt = clock();
#endif
return 0;
}