Problem Statement | |||||||||||||
You are studying public transportation, and you want to know how many buses are going down a particular one-way street every minute. You are driving along the street by car, and counting the buses you meet or overtake. After some time, you stop counting and report the result. In this problem, you may assume that the street is a straight line, and that your car and all of the buses can only go along this line in the same direction.
You will be given an int, speed, giving your speed in meters per minute. You will also be given a int[] positions, specifying how far ahead of you each of the buses is in meters at time 0, and a int[] velocities, specifying the velocities of the buses in meters per minute. The ith element of velocities and the ith element of positions specify the velocity and position of the ith bus, respectively. Finally, an int, time, tells you how many minutes you should count the buses you pass for. You should return the number of buses you will overtake or meet during time minutes. If you meet one or several buses at the first or at the final moment, count them also. | |||||||||||||
Definition | |||||||||||||
| |||||||||||||
Constraints | |||||||||||||
- | positions and velocities will contain the same number of elements. | ||||||||||||
- | positions will contain between 0 and 50 elements, inclusive. | ||||||||||||
- | speed and time will both be between 0 and 1000 inclusive. | ||||||||||||
- | All elements of positions and velocities will be between 0 and 1000, inclusive. | ||||||||||||
Examples | |||||||||||||
0) | |||||||||||||
| |||||||||||||
1) | |||||||||||||
| |||||||||||||
2) | |||||||||||||
| |||||||||||||
3) | |||||||||||||
| |||||||||||||
4) | |||||||||||||
|