-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy path1228.c
44 lines (36 loc) · 778 Bytes
/
1228.c
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
#include <iostream>
#include <vector>
using namespace std;
int find(vector<int> v, int n){
for (int i = 0; i < v.size(); i++){
if (n == v.at(i))
return i;
}
return -1;
}
int main(){
int i, j, n, p, overtakes;
vector<int> start;
vector<int> finish;
while (cin >> n){
start.clear();
finish.clear();
overtakes = 0;
for (i = 0; i < n; i++){
cin >> p;
start.push_back(p);
}
for (i = 0; i < n; i++){
cin >> p;
finish.push_back(p);
}
for (i = 0; i < n; i++){
for (j = 0; j < find(start, finish[i]); j++){
if (find(finish, start.at(j)) > i)
overtakes++;
}
}
cout << overtakes << endl;
}
return 0;
}