Bayraktar
Limits: 3 sec., 256 MiB
This statement was translated automatically from Ukrainian.
Zenyk is a Bayraktar operator. Reconnaissance reported that an occupier convoy of \(n\) trucks is planning to blow up bridges to slow down the advance of the Ukrainian army. It is known that the \(i\)-th truck is currently at coordinate \(a_i\) and contains \(b_i\) of explosives. If the \(i\)-th truck explodes, all trucks in the range \([a_i - b_i, a_i + b_i]\) will also explode. Unfortunately, the Bayraktar operated by Zenyk has only one low-power missile left, and therefore it destroys only the target it hits. Since Zenyk controls the Bayraktar very skillfully, he can hit any truck with the missile. Help Zenyk and tell him the maximum number of trucks he can blow up.
Input
The first line gives a single integer \(n\) — the number of trucks with explosives.
The second line gives \(n\) integers \(a_i\) — the coordinate of the \(i\)-th truck.
The third line gives \(n\) integers \(b_i\) — the amount of explosives in the \(i\)-th truck.
Output
In a single line, output a single integer — the maximum number of trucks that Zenyk can blow up.
Constraints
\(1 \le n \le 10^{5}\),
\(0 \le a_i, b_i \le 10^{9}\), all \(a_i\) are distinct.
Problem scoring consists of the following blocks:
1 point — the first example from the problem statement,
1 point — the second example from the problem statement,
6 points — a block of tests in which \(1 \le n \le 100\),
7 points — a block of tests in which \(1 \le n \le 3000\),
10 points — a block of tests in which \(1 \le n \le 10^{5}\),
You will receive points for a block only if you give the correct answer to all tests in the block.
Samples
| Input (stdin) | Output (stdout) |
|---|---|
| 5 1 5 7 8 9 3 2 1 2 1 | 4 |
| Input (stdin) | Output (stdout) |
|---|---|
| 6 3 2 1 7 5 9 1 0 1 2 0 0 | 3 |
Notes
In the first example, it is best to blow up the second truck, which will directly blow up the third, which in turn will blow up the fourth, which will blow up the fifth. As a result, 4 trucks will be blown up.
In the second example, it is best to blow up the fourth truck, located at coordinate 7, which will directly blow up the fifth and sixth trucks. As a result, 3 trucks will be blown up.
Submit a solution
| Element Type | Created | Who | Problem | Compiler | Result | Time (sec.) | Memory (MiB) | # | Actions |
|---|
| Element Type | Created | Who | Problem | Compiler | Result | Time (sec.) | Memory (MiB) | # | Actions |
|---|