Sonya and Hotels CodeForces - 1004A (水题)

Sonya计划开设新酒店,要求新酒店与现有酒店的最小距离为d。已知Sonya有n家酒店,分布在不同的城市坐标上,且坐标递增。问题求解在哪些城市可以新建酒店,使得新酒店与所有其他酒店的距离至少为d。输入包括n和d,以及酒店的坐标。通过分析,可以从第二个酒店开始判断左侧是否可以建酒店,最终结果需要加上首尾的可建酒店位置。
摘要由CSDN通过智能技术生成
A. Sonya and Hotels
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

Sonya decided that having her own hotel business is the best way of earning money because she can profit and rest wherever she wants.

The country where Sonya lives is an endless line. There is a city in each integer coordinate on this line. She has nn hotels, where the ii-th hotel is located in the city with coordinate xixi. Sonya is a smart girl, so she does not open two or more hotels in the same city.

Sonya understands that her business needs to be expanded by opening new hotels, so she decides to build one more. She wants to make the minimum distance from this hotel to all others to be equal to dd. The girl understands that there are many possible locations to construct such a hotel. Thus she wants to know the number of possible coordinates of the cities where she can build a new hotel.

Because Sonya is lounging in a jacuzzi in one of her hotels, she is asking you to find the number of cities where she can build a new hotel so that the minimum distance from the original nn hotels to the new one is equal to dd.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值