fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main() {
  5. ios_base::sync_with_stdio(false);
  6. cin.tie(nullptr);
  7.  
  8. const int MXN = 5e5 + 30;
  9. int n, m, k;
  10. cin >> n >> m >> k;
  11.  
  12. vector<int> a(n + 1), b(n + 1);
  13. for (int i = 1; i <= n; ++i)
  14. cin >> a[i];
  15. for (int i = 1; i <= n; ++i)
  16. cin >> b[i];
  17.  
  18. unordered_map<int, vector<int>> b_indices;
  19. for (int i = 1; i <= n; ++i)
  20. b_indices[b[i]].push_back(i);
  21.  
  22. int ans = 0;
  23. for (int i = 0; i < k; ++i) {
  24. int x;
  25. cin >> x;
  26. auto& indices = b_indices[b[x]];
  27. for (int idx : indices) {
  28. if (a[idx] > a[x]) {
  29. ++ans;
  30. break;
  31. }
  32. }
  33. }
  34.  
  35. cout << ans << endl;
  36. return 0;
  37. }
  38.  
Success #stdin #stdout 0.01s 5292KB
stdin
8 4 4
1 2 3 4 5 6 7 8
4 3 2 1 4 3 2 1
3 4 5 6
stdout
2