#abc362c. C - Sum = 0

C - Sum = 0

Score : 350350 points

问题陈述

给定 NN 对整数 (L1,R1),(L2,R2),,(LN,RN)(L_1, R_1), (L_2, R_2), \ldots, (L_N, R_N)

确定是否存在一个序列 NN 个整数 X=(X1,X2,,XN)X = (X_1, X_2, \ldots, X_N) 满足以下条件,并在存在时打印出这样的一个序列。

  • 对于每个 i=1,2,,Ni = 1, 2, \ldots, N,有 LiXiRiL_i \leq X_i \leq R_i
  • i=1NXi=0\displaystyle \sum_{i=1}^N X_i = 0

以上为大语言模型 kimi 翻译,仅供参考。

Problem Statement

You are given NN pairs of integers (L1,R1),(L2,R2),,(LN,RN)(L_1, R_1), (L_2, R_2), \ldots, (L_N, R_N).

Determine whether there exists a sequence of NN integers X=(X1,X2,,XN)X = (X_1, X_2, \ldots, X_N) that satisfies the following conditions, and print one such sequence if it exists.

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

Constraints

  • 1N2×1051 \leq N \leq 2 \times 10^5
  • 109LiRi109-10^9 \leq L_i \leq R_i \leq 10^9
  • All input values are integers.

Input

The input is given from Standard Input in the following format:

NN

L1L_1 R1R_1

L2L_2 R2R_2

\vdots

LNL_N RNR_N

Output

If no solution exists, print No. Otherwise, print an integer sequence XX that satisfies the conditions in the following format:

Yes

X1X_1 X2X_2 \ldots XNX_N

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

Sample Input 1

3
3 5
-4 1
-2 3

Sample Output 1

Yes
4 -3 -1

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

Sample Input 2

3
1 2
1 2
1 2

Sample Output 2

No

No sequence XX 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