Program time limit: 1 second
Program memory limit: 128 MB
Jack and Jill are on different points on the number line and want to meet up. Jack is at position $x$, and Jill is at position $y$. However, they can only make jumps of a certain size. Jack can make jumps of size $a_1, \dots, a_n$, while jill can make jumps of size $b_1, \dots, b_n$. (The jumps can be made in either direction).
Can Jack and Jill meet at the same position? Print Yes
if so, otherwise print
No
.
The first line of input contains space seperated integers $n$, $x$ and $y$. The second line of input contains space seperated integers $a_1, \dots, a_n$. The third line of input contains space seperated intergers $b_1, \dots, a_n$.
For all test cases:
Output a single line, containing Yes
or No
, stating whether Jack and Jill
can meet.
You should write to standard output.
In Python, you could use the line print(answer)
.
In C or C++, you could use the line printf("%d\n", answer);
.
1 1 3
14
6
Yes
Jack begins at position 1, and Jill begins at position 3. Jack can make a jump of size 14 to the right, ending on position 15. Jill can make 2 jumps of sze 12 to the right, ending on position 15. So Jack and Jill can meet at position 15.
2 4 11
4 12
6 2
No
There is no way for Jack and Jill to meet at any position.
Your program will be run on the 2 sample cases and 8 secret cases one after another. You must pass all testcases in order to score points. Recall that your final score on the task is the score of your highest scoring submission.
You haven't submitted to this task.