欢迎来到起遇信息学
起遇信息学正处于上线筹建阶段,以下功能已全部开放免费体验: ✅ 完整题库浏览与代码提交评测(C / C++ / Python / Java 等) ✅ 入门到进阶的系列课程试读、作业与考试 ✅ AI 提示、AI 作业分析等智能助教功能 ✅ 赛事模拟与个人能力报告 ✅ 邮箱注册开放 ⏳ 付费课程订阅与微信/支付宝支付通道 ⏳ 手机号登录,微信扫码登录、微信公众号绑定 使用中如遇任何问题,欢迎通过页面底部 **"联系我们"** 与我们沟通。
CF1901A.Line Trip
Line Trip
There is a road, which can be represented as a number line. You are located in the point of the number line, and you want to travel from the point to the point , and back to the point .
You travel by car, which spends liter of gasoline per unit of distance travelled. When you start at the point , your car is fully fueled (its gas tank contains the maximum possible amount of fuel).
There are gas stations, located in points . When you arrive at a gas station, you fully refuel your car. Note that you can refuel only at gas stations, and there are no gas stations in points and .
You have to calculate the minimum possible volume of the gas tank in your car (in liters) that will allow you to travel from the point to the point and back to the point .
Input
The first line contains one integer () — the number of test cases.
Each test case consists of two lines:
- the first line contains two integers and (; );
- the second line contains integers ($0 \lt a_1 \lt a_2 \lt \dots \lt a_n \lt x$).
Output
For each test case, print one integer — the minimum possible volume of the gas tank in your car that will allow you to travel from the point to the point and back.
Note
In the first test case of the example, if the car has a gas tank of liters, you can travel to and back as follows:
- travel to the point , then your car's gas tank contains liters of fuel;
- refuel at the point , then your car's gas tank contains liters of fuel;
- travel to the point , then your car's gas tank contains liters of fuel;
- refuel at the point , then your car's gas tank contains liters of fuel;
- travel to the point , then your car's gas tank contains liter of fuel;
- refuel at the point , then your car's gas tank contains liters of fuel;
- travel to the point , then your car's gas tank contains liters of fuel;
- travel to the point , then your car's gas tank contains liters of fuel;
- refuel at the point , then your car's gas tank contains liters of fuel;
- travel to the point , then your car's gas tank contains liter of fuel;
- refuel at the point , then your car's gas tank contains liters of fuel;
- travel to the point , then your car's gas tank contains liters of fuel;
- refuel at the point , then your car's gas tank contains liters of fuel;
- travel to the point , then your car's gas tank contains liters of fuel.
Samples
3
3 7
1 2 5
3 6
1 2 5
1 10
7
4
3
7
在线编程 IDE
建议全屏模式获得最佳体验
| 进入全屏编程 | Alt+E |
| 递交评测 | Ctrl+Enter |
| 注释/取消注释 | Ctrl+/ |
| 缩放字体 | Ctrl+滚轮 |