-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path2002.cpp
More file actions
41 lines (36 loc) · 849 Bytes
/
2002.cpp
File metadata and controls
41 lines (36 loc) · 849 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
#include <iostream>
#include <algorithm>
#include <stack>
#include <vector>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(NULL);
int n;
vector<string> input;
vector<string> output;
int overtake_count = 0;
cin >> n;
for (int i = 0; i < n; i++) {
string s;
cin >> s;
input.push_back(s);
}
for (int i = 0; i < n; i++) {
string s;
cin >> s;
output.push_back(s);
}
vector<string>::iterator iter;
for (int i = n - 1; i >= 0; i--) {
iter = find(output.begin(), output.end(), input[i]);
if (iter != output.end()) {
if (iter - output.begin() < i) {
output.erase(iter);
overtake_count++;
}
}
}
cout << overtake_count << "\n";
return 0;
}