Malinovsky239

Untitled

Sep 25th, 2012
2,625
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <algorithm>
  2. #include <iostream>
  3. #include <cstdlib>
  4. #include <cstring>
  5. #include <cassert>
  6. #include <cstdio>
  7. #include <vector>
  8. #include <cctype>
  9. #include <string>
  10. #include <ctime>
  11. #include <cmath>
  12. #include <set>
  13. #include <map>
  14.  
  15. typedef long double LD;
  16. typedef long long LL;
  17.  
  18. using namespace std;
  19.  
  20. #define sz(A) (int)(A).size()
  21. #define mp make_pair
  22. #define pb push_back
  23.  
  24. const int N = int(1e5 + 3);
  25.  
  26. int n, m, pos[N];
  27.  
  28. int main() {
  29.     scanf("%d", &n);   
  30.     for (int i = 0; i < n; i++) {
  31.         int num;
  32.         scanf("%d", &num);
  33.         pos[num] = i + 1;
  34.     }  
  35.  
  36.     LL sum1 = 0, sum2 = 0;
  37.  
  38.     scanf("%d", &m);   
  39.     for (int i = 0; i < m; i++) {
  40.         int q;
  41.         scanf("%d", &q);
  42.         sum1 += pos[q];
  43.         sum2 += n - pos[q] + 1;            
  44.     }
  45.  
  46.     printf("%I64d %I64d\n", sum1, sum2);
  47.  
  48.     return 0;
  49. }
RAW Paste Data