Preparando MOJI

Ball

2000ms 262144K

Description:

N ladies attend the ball in the King's palace. Every lady can be described with three values: beauty, intellect and richness. King's Master of Ceremonies knows that ladies are very special creatures. If some lady understands that there is other lady at the ball which is more beautiful, smarter and more rich, she can jump out of the window. He knows values of all ladies and wants to find out how many probable self-murderers will be on the ball. Lets denote beauty of the i-th lady by Bi, her intellect by Ii and her richness by Ri. Then i-th lady is a probable self-murderer if there is some j-th lady that Bi < Bj, Ii < Ij, Ri < Rj. Find the number of probable self-murderers.

Input:

The first line contains one integer N (1 ≤ N ≤ 500000). The second line contains N integer numbers Bi, separated by single spaces. The third and the fourth lines contain sequences Ii and Ri in the same format. It is guaranteed that 0 ≤ Bi, Ii, Ri ≤ 109.

Output:

Output the answer to the problem.

Sample Input:

3
1 4 2
4 3 2
2 5 3

Sample Output:

1

Informação

Codeforces

Provedor Codeforces

Código CF12D

Tags

data structuressortings

Submetido 0

BOUA! 0

Taxa de BOUA's 0%

Datas 09/05/2023 08:26:49

Relacionados

Nada ainda