CF1921C Sending Messages
题目描述
Stepan是一个busy的人。今天,他需要在 $m_1,m_2,\dots m_n$ 时刻发送 $n$ 条信息。很惨的是,到 $0$ 时刻,他的手机只剩 $f$ 个单位电量。此时手机已开机。
手机每开机一时刻就会损失 $a$ 个单位电量。此外,Stepan可以随时关闭手机,稍后再开机,每次共消耗 $b$ 个单位的能量。开关机不花费任何时间,这样就可以在 $x$ 时刻打开它,同时发送信息,反之,在 $x$ 时刻发送信息同时关闭手机也是可以的。
如果在任何时候电量降至 $0$ 以下,则手机自动关机,无法发送消息。Stepan想知道是否可以在不给手机充电的情况下发送所有信息。
输入格式
_**本题包含多组测试数据。**_
第一行一个整数 $T$( $ 1 \le T \le 10^4 $ ) ,表示测试用例数量。
对于每个测试用例,第一行输入四个整数 $n,f,a,b$( $ 1 \le n \le 2 \cdot 10^5 $ , $ 1 \le f, a, b \le 10^9 $ ) ,意义已给出。第二行输入 $n$ 个整数 $m_1,m_2,\dots m_n$( $ 1 \le m_i \le 10^9 $ ) ,保证其单调递增。
输出格式
对于每个测试用例,输出字符串 ```YES``` 或 ```NO``` 的一种,表示是否能发送所有信息。
说明/提示
In the first test case of the example, at moment $ 0 $ , the phone's charge is $ 3 $ . When sending a message at moment $ 3 $ without turning it off, $ (3 - 0) \cdot 1 = 3 $ units of charge will be spent. In this case, the charge will drop to $ 0 $ and Stepan will not be able to send the message. When turning off and on, the phone's charge will decrease by $ 5 $ , so it will not be possible to send the message in this way.
In the third test case of the example, at moment $ 0 $ , the phone's charge is $ 10 $ . The phone loses $ 1 $ unit of charge per unit of time, and when turned off and on, it loses $ 2 $ units of charge. To send all messages, the following actions can be taken:
- Turn off the phone at moment $ 0 $ and turn it on at moment $ 1 $ , after which $ 10 - 2 = 8 $ units of charge will remain;
- send a message at moment $ 1 $ ;
- send a message at moment $ 2 $ , after which $ 8 - (2 - 1) \cdot 1 = 7 $ units of charge will remain;
- Turn off the phone at moment $ 2 $ and turn it on at moment $ 3 $ , after which $ 7 - 2 = 5 $ units of charge will remain;
- send a message at moment $ 3 $ ;
- Turn off the phone at moment $ 3 $ and turn it on at moment $ 4 $ , after which $ 5 - 2 = 3 $ units of charge will remain;
- send a message at moment $ 4 $ ;
- Turn off the phone at moment $ 4 $ and turn it on at moment $ 5 $ , after which $ 3 - 2 = 1 $ unit of charge will remain;
- send a message at moment $ 5 $ .
The last (sixth) test set of the example may fail if there is an integer overflow in your solution.