forked from mpfeifer1/Kattis
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhorrorfilmnight.cpp
51 lines (43 loc) · 912 Bytes
/
horrorfilmnight.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
#include <iostream>
#include <vector>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(NULL);
vector<bool> v1, v2;
v1.resize(1000000, false);
v2.resize(1000000, false);
int s;
cin >> s;
for(int i = 0; i < s; i++) {
int temp;
cin >> temp;
v1[temp] = true;
}
cin >> s;
for(int i = 0; i < s; i++) {
int temp;
cin >> temp;
v2[temp] = true;
}
bool h1 = true, h2 = true;
int total = 0;
for(int i = 0; i < 1000000; i++) {
if(v1[i] && v2[i]) {
h1 = true;
h2 = true;
total++;
}
else if(v1[i] && h2) {
h1 = true;
h2 = false;
total++;
}
else if(v2[i] && h1) {
h1 = false;
h2 = true;
total++;
}
}
cout << total << endl;
}