#P8667. [蓝桥杯 2018 省 B] 递增三元组

    ID: 9863 远端评测题 1000ms 256MiB 尝试: 20 已通过: 5 难度: 5 上传者: 标签>动态规划 DP2018二分枚举蓝桥杯省赛

[蓝桥杯 2018 省 B] 递增三元组

Problem Description

Given three integer arrays A=[A1,A2,,AN]A = [A_1, A_2,\cdots, A_N], B=[B1,B2,,BN]B = [B_1, B_2,\cdots, B_N], and C=[C1,C2,,CN]C = [C_1, C_2,\cdots,C_N].

Please count how many triples (i,j,k)(i, j, k) satisfy:

  1. 1i,j,kN1 \le i, j, k \le N.
  2. Ai<Bj<CkA_i < B_j < C_k.

Input Format

The first line contains an integer NN.

The second line contains NN integers A1,A2,,ANA_1, A_2,\cdots, A_N.

The third line contains NN integers B1,B2,,BNB_1, B_2,\cdots, B_N.

The fourth line contains NN integers C1,C2,,CNC_1, C_2,\cdots, C_N.

Output Format

Output one integer representing the answer.

3
1 1 1
2 2 2
3 3 3
27

Hint

For 30%30\% of the testdata, 1N1001 \le N \le 100.

For 60%60\% of the testdata, 1N10001 \le N \le 1000.

For 100%100\% of the testdata, 1N1051 \le N \le 10^5, and 0Ai,Bi,Ci1050 \le A_i, B_i, C_i \le 10^5.

Translated by ChatGPT 5