#P7375. [COCI 2018/2019 #5] Jarvis

[COCI 2018/2019 #5] Jarvis

Description

Ivan has NN drones. Each drone has a factory attribute value and a required attribute value for deployment. He can choose an integer XX (XX is not necessarily positive) and add XX to the factory attribute value of every drone.

Find the maximum number of drones that can be deployed (that is, whose attribute value becomes equal to the required attribute value for deployment).

Input Format

The first line contains an integer NN, the number of drones.

The second line contains NN integers AiA_i, the factory attribute values of the drones.

The third line contains NN integers BiB_i, the required attribute values for deployment of the drones.

Output Format

Output the maximum number of drones that can be deployed.

1
1
2
1
2
0 0
1 1
2
2
1 2
5 5
1

Hint

Explanation for Sample 3

If we choose X=3X=3, the attribute values become 1+3=41+3=4 and 2+3=52+3=5, so only the second drone can be deployed. If X=4X=4, the attribute values become 55 and 66, so only the first drone can be deployed. It can be proven that there is no integer XX that allows both drones to be deployed.

Constraints

For 40%40\% of the testdata, 10Ai,Bi10-10 \le A_i,B_i \le 10.

For 100%100\% of the testdata, 1N1051 \le N \le 10^5, 106Ai,Bi106-10^6 \le A_i,B_i \le 10^6.

Notes

The score of this problem follows the original COCI setting, with a full score of 7070.

Translated from COCI2018-2019 CONTEST #5 T2 Jarvis.

Translated by ChatGPT 5