|
||||||||||
Fluctuation LimitTime Limit: 2000/2000 MS (Java/Others) Memory Limit: 524288/524288 K (Java/Others)Total Submission(s): 990 Accepted Submission(s): 430 Special Judge Problem Description It is preferrable to read the pdf statment. Cuber QQ has signed up for a gambling game, that challenges him to predict the stock price of Quber CC Limited, for the next following $n$ days. He shall make his prediction by filling a table with $n$ intervals, the $i$-th of which is the predicted interval $[l_i, r_i]$ at the $i$-th day. If all $n$ prices lie in the corresponding interval, Cuber QQ will win 1 million dollars. Otherwise, he will not earn a single penny. As is well known, the stock price has a fluctuation limit. For simplicity, we assume the limit up and the limit down are both $k$, which is an integer. That means, if the stock price at the $i$-th day is $x$, the price at the $i+1$-th day is at most $x+k$ and at least $x-k$. Cuber QQ wants to know whether it is possible to manipulate the stock price, without breaking the limitation above of course, so that he can have the $1$ million dollars. Since his table has already been submitted, he cannot modify his predicted intervals any more. It has to be done secretly behind the scenes, and smartly cover it up so that no one will notice. Input The input starts with an integer $T$ ($1 \le T \le 10^5$), denoting the number of test cases. For each test case, the first line contains two space-separated integers $n$ and $k$ ($2 \le n \le 10^5$, $0 \le k \le 10^9$), where $n$ is the number of days and $k$ is the fluctuation limit. The $i$-th line of the next $n$ lines contains two space-separated integers $l_i$ and $r_i$ ($0 \le l_i \le r_i \le 10^9$), which is Cuber QQ's predicted interval in the $i$-th day. A prediction is believed to be correct if the stock price $i$-th day lies between $l_i$ and $r_i$, inclusive. It is guaranteed that the sum of all $n$ does not exceed $10^6$. Output For each test case, first output a single line YES or NO, that states whether Cuber QQ will win the 1 million price. If YES, in the next line, output a possible price series, $a_1, a_2, \ldots, a_n$, where $l_i \le a_i \le r_i$ ($1 \le i \le n$) and $|a_i - a_{i+1}| \le k$ ($1 \le i \le n - 1$). The integers should be separated with space. Sample Input
Sample Output
Source | ||||||||||
|