当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

6860:Fluctuation Limit

Special Judge 特殊评判
题目描述
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.
输入解释
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$.
输出解释
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.
输入样例
2
3 1
1 6
2 5
3 6
2 3
1 5
10 50
输出样例
YES
2 3 3
NO
来自杭电HDUOJ的附加信息
Recommend IceyWang

该题目是Virtual Judge题目,来自 杭电HDUOJ

源链接: HDU-6860

最后修改于 2020-10-25T23:35:00+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
2000/2000MS(Java/Others) 524288/524288K(Java/Others)