No.1623 Making Triangles
Problem Statement
There are $n$ sticks of each color: red, green, and blue. The lengths of the $i$-th stick of each color are $r_i, g_i, b_i$, respectively.
When making a triangle using the $i$-th red stick, the $j$-th green stick, and the $k$-th blue stick, compute the number of integer tuples $(i, j, k)$ such that a triangle with positive area is formed and $r_i = \max(r_i, g_j, b_k)$ is satisfied.
Constraints
Input
$n$ $r_1\ r_2\ \dots\ r_n$ $g_1\ g_2\ \dots\ g_n$ $b_1\ b_2\ \dots\ b_n$
Output
Output the answer on one line. End the output with a newline.
Sample
Sample 1
Input
2 2 3 3 2 1 2
Output
5
Only $(i, j, k) = (1, 2, 1), (1, 2, 2), (2, 1, 1), (2, 1, 2), (2, 2, 2)$ satisfy the conditions.
Sample 2
Input
5 123 456 789 987 654 321 231 1 1 2 2 3 500 1000 1000
Output
3
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。
null
sak