-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path6900.cpp
More file actions
48 lines (46 loc) · 926 Bytes
/
6900.cpp
File metadata and controls
48 lines (46 loc) · 926 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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
// 6900. 주혁이의 복권 당첨
// 2019.06.29
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main()
{
int t;
cin >> t;
for (int testCase = 1; testCase <= t; testCase++)
{
int n, m;
cin >> n >> m;
pair<string, int> items[101]; // 당첨번호와 당첨금액 저장
for (int i = 0; i < n; i++)
{
cin >> items[i].first >> items[i].second;
}
int ans = 0;
for (int i = 0; i < m; i++)
{
string s;
cin >> s;
// 2중 for문으로 당첨 확인
for (int j = 0; j < n; j++)
{
for (int k = 0; k < s.size(); k++)
{
// 당첨되지 않았을 때
if (s[k] != items[j].first[k] && items[j].first[k] != '*')
{
break;
}
// 당첨되었을때
if (s[k] == items[j].first[k] && k == s.size() - 1)
{
ans += items[j].second;
}
}
}
}
cout << "#" << testCase << " " << ans << endl;
}
return 0;
}