Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <vector>
- #include <algorithm>
- using namespace std;
- int main()
- {
- int n;
- cin >> n;
- vector<int> arr(n);
- int x;
- for(int i = 0; i < n; i++){
- cin >> x;
- arr[x] = i;
- }
- int m;
- cin >> m;
- int qu;
- long long first = 0, second = 0;
- for(int i = 0; i < m; i++) {
- cin >> qu;
- int x = arr[qu] + 1;
- first += x;
- second += n - x + 1;
- }
- cout << first << " " << second;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement