Skip to content
Onsite

Marathon Start Points

EasyP3Coding

A marathon ends at position 100000. There are several start points; start point i is at positions[i] and holds an energy drink worth energy[i] units. A runner begins at a start point with zero energy, drinks that point's drink, and can then run exactly energy[i] units (1 unit of energy covers 1 unit of distance). The runner does not pick up any other drink on the way.

Return the number of start points from which the runner can reach position 100000 or further.

Example 1

Input
positions = [99990,50000,99999], energy = [10,5,1]
Output
2

Example 2

Input
positions = [0], energy = [100000]
Output
1

Example 3

Input
positions = [0], energy = [99999]
Output
0

Constraints

  • 0 <= positions.length == energy.length <= 10^5
  • 0 <= positions[i] <= 100000
  • 0 <= energy[i] <= 10^5

Hints

Run checks the 3 visible tests, Submit all 10.