SHARE
TWEET

5

sharnoby Jul 16th, 2019 72 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <string>
  3. #include <vector>
  4. #include <algorithm>
  5.  
  6. using namespace std;
  7.  
  8. int main()
  9. {
  10.     int n;
  11.     cin >> n;
  12.     vector<int> arr(n);
  13.     int x;
  14.     for(int i = 0; i < n; i++){
  15.         cin >> x;
  16.         arr[x] = i;
  17.     }
  18.     int m;
  19.     cin >> m;
  20.     int qu;
  21.     long long first = 0, second = 0;
  22.     for(int i = 0; i < m; i++) {
  23.         cin >> qu;
  24.         int x = arr[qu] + 1;
  25.         first += x;
  26.         second += n - x + 1;
  27.     }
  28.     cout << first << " " << second;
  29.  
  30.     return 0;
  31. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top