P8667 [Lanqiao Cup 2018 NOI Qualifier B] Increasing Triples

Description

Given three integer arrays $A = [A_1, A_2,\cdots, A_N]$, $B = [B_1, B_2,\cdots, B_N]$, and $C = [C_1, C_2,\cdots,C_N]$. Please count how many triples $(i, j, k)$ satisfy: 1. $1 \le i, j, k \le N$. 2. $A_i < B_j < C_k$.

Input Format

The first line contains an integer $N$. The second line contains $N$ integers $A_1, A_2,\cdots, A_N$. The third line contains $N$ integers $B_1, B_2,\cdots, B_N$. The fourth line contains $N$ integers $C_1, C_2,\cdots, C_N$.

Output Format

Output one integer representing the answer.

Explanation/Hint

For $30\%$ of the testdata, $1 \le N \le 100$. For $60\%$ of the testdata, $1 \le N \le 1000$. For $100\%$ of the testdata, $1 \le N \le 10^5$, and $0 \le A_i, B_i, C_i \le 10^5$. Translated by ChatGPT 5