aboutsummaryrefslogtreecommitdiff
path: root/store/works/solutions/acwing/1236.cpp
blob: a89a89084fe20464cb20d064044ee6d9ba7f50b8 (plain)
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
44
45
46
47
48
49
50
51
52
53
54
#include <iostream>

const int MAX = 100000;
const int MM = 100010;

int N;

long long ca[MM];
long long cb[MM];

int main() {
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(nullptr);

  std::cin >> N;

  for (int i = 0; i < N; i++) {
    int a;
    std::cin >> a;
    ca[a]++;
  }

  for (int n = 1; n <= MAX; n++) {
    ca[n] = ca[n - 1] + ca[n];
  }

  for (int i = 0; i < N; i++) {
    int b;
    std::cin >> b;
    cb[b]++;
  }

  for (int n = 1; n <= MAX; n++) {
    cb[n] *= ca[n - 1];
  }

  for (int n = 2; n <= MAX; n++) {
    cb[n] = cb[n - 1] + cb[n];
  }

  long long result = 0;

  for (int i = 0; i < N; i++) {
    int c;
    std::cin >> c;
    if (c >= 2) {
      result += cb[c - 1];
    }
  }

  std::cout << result;

  return 0;
}