-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcd.cpp
38 lines (38 loc) · 810 Bytes
/
cd.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
// GitHub: EntityPlantt/Kattis
// Time Limit Exceeded
#include <iostream>
#include <vector>
using namespace std;
main() {
size_t n, m, x, t, i;
while (true) {
cin >> n >> m;
if (!n && !m) {
break;
}
t = i = 0;
vector <size_t> jack;
while (n--) {
cin >> x;
jack.push_back(x);
}
while (m--) {
cin >> x;
if (i >= jack.size()) {
break;
}
while (jack[i] < x) {
i++;
if (i >= jack.size()) {
break;
}
}
if (i >= jack.size()) {
break;
}
t += jack[i] == x;
}
cout << t << '\n';
}
return 0;
}