-
Notifications
You must be signed in to change notification settings - Fork 0
/
57834925.cpp
57 lines (57 loc) · 1.11 KB
/
57834925.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>
using namespace std;
int main()
{
int n;
cin>>n;
int askill[102]={0};
for(int i=1;i<=n;i++)
{
int k;
cin>>k;
askill[k]+=1;
}
int m;
cin>>m;
int bskill[102]={0};
for(int i=1;i<=m;i++)
{
int k;
cin>>k;
bskill[k]+=1;
}
int result=0;
for(int i=1;i<=100;i++)
{
if(askill[i]>=1)
{
if(bskill[i-1]>=1)
{
askill[i]-=1;
bskill[i-1]-=1;
result++;
i--;
continue;
}
if(bskill[i]>=1 && askill[i]>=1)
{
askill[i]-=1;
bskill[i]-=1;
result++;
i--;
continue;
}
if(bskill[i+1]>=1 && askill[i]>=1)
{
askill[i]-=1;
bskill[i+1]-=1;
result++;
i--;
continue;
}
}
//cout<<"i="<<i<<" result="<<result<<endl;
}
cout<<result<<endl;
return 0;
}