Barbie's Gold and Silver Collection
Barbie is standing under a tree. When she shakes the tree, several gold coins and silver coins fall. The coins fall in a straight line relative to Barbie's position.
You need to determine how many gold coins and silver coins land within a specific range where Barbie can collect them. The range is defined by the starting and ending points relative to Barbie's position.
Input Format
- An integer,
s
, the starting point of Barbie's collection range. - An integer,
t
, the ending point of Barbie's collection range. - An integer,
x
, the position of Barbie under the tree. - Two integers,
m
andn
, the number of gold coins and silver coins that fall from the tree, respectively. - An array of
m
integers, where each element represents the distance a gold coin falls relative to the tree position. - An array of
n
integers, where each element represents the distance a silver coin falls relative to the tree position.
Output Format
Print two integers:
- The number of gold coins collected by Barbie.
- The number of silver coins collected by Barbie.
Constraints
Sample Input 1
Sample Output 1
Explanation
- The collection range is [7, 10].
- The tree is at position 5.
- Gold coins fall at positions: , ,
- Tow coins coin (at position 7 and 8) are within Barbie's range.
- Silver coins fall at positions: , , .
- One coin (at position 7) iswithin Barbie's range.
Sample Input 2
Sample Output 2
Solution Code
Comments
Post a Comment