eolymp
bolt
Try our new interface for solving problems
Problems

Count the triplets

Count the triplets

Given three array $a, b$ and $c$ of $n$ integers each. Find the number of triplets $(a_i, b_j, c_k)$ such that $a_i < b_j < c_k$. \InputFile First line contains the size of arrays $n\:(n \le 10^5)$. Second line contains elements of array $a$. Next line contains elements of array $b$. Last line contains elements of array $c$. \OutputFile Print the number of triplets $(a_i, b_j, c_k)$ such that $a_i < b_j < c_k$. \Note In the first test we have triples $(a_1, b_1, c_1), (a_1, b_2, c_1)$ and $(a_1, b_2, c_2)$.
Time limit 2 seconds
Memory limit 128 MiB
Input example #1
2
1 5
4 2
6 3
Output example #1
3
Input example #2
3
1 1 1
2 2 2
3 3 3
Output example #2
27