Problems
An entrepreneur has
The entrepreneur wants to distribute all of these blueprints among their two children Alice and Bob. Each child will build exactly one building from each blueprint allocated to them, choosing the number of residential floors for each building.
The entrepreneur wants to avoid showing favoritism towards either child, so they are looking for a fair distribution of the blueprints. They decided that a fair distribution is one in which it is possible to construct the buildings in such a way that the sum of the heights of the buildings constructed by each child is the same. Can you tell whether a fair distribution exists?
Consider the following example for
G = 1 andR = 1 (possible heights are2, 3, 4, \dots );G = 0 andR = 3 (no ground floor, possible heights are3, 6, 9, \dots );G = 2 andR = 1 (possible heights are3, 4, 5, \dots ).
In this case a possible fair distribution is assigning the second blueprint to Alice and the rest to Bob. Even though Alice receives a single blueprint while Bob receives two, they may construct two residential floors on the first building type (height
Input
The first line contains an integer
Each of the next
Output
Output a single line with the uppercase letter “Y” if there exists a fair distribution of the blueprints, and the uppercase letter “N” otherwise.
Subtask
| # | Score | Condition |
|---|---|---|
| #1 | 12 | |
| #2 | 2 | |
| #3 | 18 | |
| #4 | 23 | No additional constraints. |
| #5 | 45 | |
Example #1
3
1 1
0 3
2 1
Y
Example #2
3
3 2
2 1
3 2
Y
Example #3
3
1 10
2 20
4 30
N
Example #4
1
1 1
N