P24781 [AtCoder] Sum = 0
普及-
题目描述

Problem Statement

You are given N pairs of integers $(L_1, R_1), (L_2, R_2), \ldots, (L_N, R_N)$.
Determine whether there exists a sequence of $N integers X = (X_1, X_2, \ldots, X_N)$ that satisfies the following conditions, and print one such sequence if it exists.

  • $L_i \leq X_i \leq R_i$ for each $i = 1, 2, \ldots, N$.
  • $\displaystyle \sum_{i=1}^N X_i = 0$.

Input

The input is given from Standard Input in the following format:
N
L_1 R_1
L_2 R_2
$\vdots$
L_N R_N

Output

If no solution exists, print No. Otherwise, print an integer sequence X that satisfies the conditions in the following format:
Yes
$X_1 X_2 \ldots X_N$

If multiple solutions exist, any of them will be considered correct.

Constraints

  • $1 \leq N \leq 2 \times 10^5$
  • -$10^9 \leq L_i \leq R_i \leq 10^9$
  • All input values are integers.

Sample Input 1

3
3 5
-4 1
-2 3

Sample Output 1

Yes
4 -3 -1

The sequence X = (4, -3, -1) satisfies all the conditions. Other valid sequences include (3, -3, 0) and (5, -4, -1).

Sample Input 2

3
1 2
1 2
1 2

Sample Output 2

No

No sequence X satisfies the conditions.

Sample Input 3

6
-87 12
-60 -54
2 38
-76 6
87 96
-17 38

Sample Output 3

Yes
-66 -57 31 -6 89 9

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
3 3 5 -4 1 -2 3
样例输出
Yes 4 -3 -1