Problem Statement | |||||||||||||
A group of swimmers are stretching along the shores of a river. In just a few moments, they are all going to plunge in, swim downstream (with the current) for a specific distance (unique to each swimmer), and return back (against the current) to their starting points. Relative to a person on the shore, the speed at which each swimmer travels when swimming downstream is the swimmer's speed plus the speed of the current, and the speed at which each swimmer travels when swimming upstream is the swimmer's speed minus the speed of the current. Assume that no time elapses when a swimmer turns around to make the return trip. Write a class Swimmers with a method getSwimTimes which takes a int[] distances (meters relative to the shore) each swimmer will be swimming, a int[] speeds (meters per second) at which they swim, and an int current representing the speed (meters per second) of the current in the river. Element i in distances corresponds to element i in speeds. The method should return a int[] of the times (rounded down to the nearest integer less than or equal to the actual value) that the roundtrip swim took for each swimmer, or "-1" if the trip is impossible to make. Element i in the returned int[] should correspond to element i in distances and speeds. | |||||||||||||
Definition | |||||||||||||
| |||||||||||||
Constraints | |||||||||||||
- | distances contains between 0 and 50 elements, inclusive | ||||||||||||
- | each element of distances will be between 0 and 10000, inclusive | ||||||||||||
- | speeds will have the same number of elements as distances | ||||||||||||
- | each element of speeds will be between 0 and 100, inclusive | ||||||||||||
- | current will be between 0 and 100, inclusive | ||||||||||||
Examples | |||||||||||||
0) | |||||||||||||
| |||||||||||||
1) | |||||||||||||
| |||||||||||||
2) | |||||||||||||
| |||||||||||||
3) | |||||||||||||
| |||||||||||||
4) | |||||||||||||
|