#P11299. Contest Score Weight Selection
Contest Score Weight Selection
Contest Score Weight Selection
There are N contestants participating in a contest which is held in 2 rounds. The ith contestant scores Ai points in round one and Bi points in round two. In each round, a positive integer weight is assigned — X for round one and Y for round two. The final score for the ith contestant is computed as:
You, as the contest organizer, can freely choose the weights X and Y (both must be positive integers). However, Squeaky, a bribing mouse, wants you to pick the weights in such a way that for every pair of contestants with indices i < j, the following holds:
In other words, the scores must be strictly decreasing from the first contestant to the last. Is it possible to choose positive integers X and Y to satisfy this condition? If yes, output Yes, otherwise output No.
inputFormat
The input consists of three lines:
- The first line contains a single integer N (the number of contestants).
- The second line contains N integers A1, A2, ..., AN separated by spaces.
- The third line contains N integers B1, B2, ..., BN separated by spaces.
You can assume that all input numbers are integers and that N ≥ 2.
outputFormat
Output a single string: Yes if it is possible to choose positive integers X and Y so that for every 1 ≤ i < j ≤ N, Si > Sj holds; otherwise, output No.
sample
3
3 2 1
1 2 3
Yes