electicode
HomeCoursesResourcesProblemsNational OlympiadContestsLeaderboard
...

4D Objects

Time Limit: 1500msMemory Limit: 256MB
View Submissions

Problem Description

There are nnn objects. For the iii-th object, its value is sis_isi​, and you may choose any real number viv_ivi​ such that xi≤vi≤yix_i \le v_i \le y_ixi​≤vi​≤yi​. Define the score of the iii-th object as sivi\frac{s_i}{v_i}vi​si​​.

An object is called good if there exists a choice of values v1,v2,…,vnv_1, v_2 , \ldots , v_nv1​,v2​,…,vn​ such that its score is not greater than the score of any other object. If several objects have the same minimum score, all of them are considered good. Find the number of good objects.

Input Format

The first line contains an integer nnn (1≤n≤105)(1 \le n \le 10^5 )(1≤n≤105).

The second line contains nnn integers s1,s2,…,sns_1 , s_2 , \ldots, s_ns1​,s2​,…,sn​ .

The third line contains nnn integers x1,x2,…,xnx_1 , x_2 , \ldots , x_nx1​,x2​,…,xn​ .

The fourth line contains nnn integers y1,y2,…,yny_1 , y_2 , \ldots , y_ny1​,y2​,…,yn​ .

It is guaranteed that xi≤yix_i \le y_ixi​≤yi​ for each 1≤i≤n1 \le i \le n1≤i≤n.

Output Format

Print the number of good objects.

Examples

Example 1
Input
4
15 10 50 100
2 3 1 20
7 4 1 50
Output
3
Explanation

In the first sample, the first, second, and fourth objects are good, while the third one is not.

Example 2
Input
2
7 7
1 1
1 1
Output
2
Explanation

In the second sample, both objects always have the same score, so both are good.

© 2026 Electicode. All rights reserved.

(1≤si≤106)(1 \le s_i \le 10^6)
(1≤si​≤106)
(1≤xi≤103)(1 ≤ x_i \le 10^3)
(1≤xi​≤103)
(1≤yi≤103)(1 \le y_i \le 10^3)
(1≤yi​≤103)