atcoder#APC001B. Two Arrays
Two Arrays
Score : points
Problem Statement
You are given two integer sequences of length : and . Determine if we can repeat the following operation zero or more times so that the sequences and become equal.
Operation: Choose two integers and (possibly the same) between and (inclusive), then perform the following two actions simultaneously:
- Add to .
- Add to .
Constraints
- ()
- All input values are integers.
Input
Input is given from Standard Input in the following format:
Output
If we can repeat the operation zero or more times so that the sequences and become equal, print Yes
; otherwise, print No
.
3
1 2 3
5 2 2
Yes
For example, we can perform three operations as follows to do our job:
- First operation: and . Now we have , .
- Second operation: and . Now we have , .
- Third operation: and . Now we have , .
5
3 1 4 1 5
2 7 1 8 2
No
5
2 7 1 8 2
3 1 4 1 5
No