| 시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
|---|---|---|---|---|---|
| 1 초 (추가 시간 없음) | 1024 MB | 171 | 58 | 46 | 31.507% |
An entrepreneur has $N$ blueprints, each describing a type of building. Each blueprint specifies the building’s height through two integers $G$ and $R$.
$G$: Height of the ground floor. It can be zero, indicating that the building has no ground floor.
$R$: Height of each residential floor. Each building has at least one residential floor.
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 $N = 3$ blueprints:
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 3ドル$), two residential floors on the second (height 6ドル$), and one residential floor on the third (height 3ドル$). In this way, the sum of the heights of the buildings constructed by each child would be 6ドル$.
The first line contains an integer $N$ (1ドル ≤ N ≤ 2 \cdot 10^5$) indicating the number of blueprints.
Each of the next $N$ lines contains two integers $G$ (0ドル ≤ G ≤ 2 \cdot 10^5$) and $R$ (1ドル ≤ R ≤ 10^9$) denoting respectively the height of the ground floor and the height of each residential floor specified by the corresponding blueprint. The sum of the heights of the ground floors of all blueprints is at most 2ドル \cdot 10^5$.
Output a single line with the uppercase letter “Y” if there exists a fair distribution of the blueprints, and the uppercase letter “N” otherwise.
3 1 1 0 3 2 1
Y
3 3 2 2 1 3 2
Y
3 1 10 2 20 4 30
N
1 1 1
N