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.

Input

The first line contains two integers nn and dd (1≤n≤1001≤n≤100, 1≤d≤1091≤d≤109) — the number of Sonya's hotels and the needed minimum distance from a new hotel to all others.

The second line contains nn different integers in strictly increasing order x1,x2,…,xnx1,x2,…,xn (−109≤xi≤109−109≤xi≤109) — coordinates of Sonya's hotels.

Output

Print the number of cities where Sonya can build a new hotel so that the minimum distance from this hotel to all others is equal to dd.

Examples
input

Copy

4 3
-3 2 9 16

output

Copy

6

input

Copy

5 2
4 8 11 18 19

output

Copy

5

Note

In the first example, there are 66 possible cities where Sonya can build a hotel. These cities have coordinates −6−6, 55, 66, 1212, 1313, and 1919.

In the second example, there are 55 possible cities where Sonya can build a hotel. These cities have coordinates 22, 66, 1313, 1616, and 2121

有一个长为n的地方可以放rose和lily两种花,有d位游客,每位游览不同的区间,现要求每位游客游览的区间内rose数乘Lily数最大,想了好久,以为是爆搜或者是动态规划一类的难题,果断放弃。

晚上搜题解,才发现是一道考验智商的大水题,只需保证0101010这样的顺序就可以保证每位游客经历的区间不同花的个数最多了。深感遗憾和震惊!!!!

#include<bits/stdc++.h>
using namespace std;int main()
{int a,b,t;scanf("%d%d",&a,&b);for(int i=0;i<b;i++){cin>>t;cin>>t;}for(int i=0;i<a;i++){if(i&1)cout<<'1';elsecout<<'0';}cout<<endl;return 0;
}

CF B. Sonya and Exhibition相关推荐

  1. Sonya and Exhibition 【模拟】

    题目链接:https://cn.vjudge.net/contest/280309#problem/J 题目描述 Sonya decided to organize an exhibition of ...

  2. CodeForces - 1004B - Sonya and Exhibition(纯思维题)

    题目链接: http://codeforces.com/problemset/problem/1004/B 题目: Sonya decided to organize an exhibition of ...

  3. 常用技巧 —— 打表规律

    [概述] 找规律是一种常见的题型,当给出相关数据后,我们往往可以利用打表的方法,得到大量的数据,然后再寻找规律. 简单来说,打表就是需要对某个范围内的数据进行判断,判断它是否符合某种条件,然后在接下来 ...

  4. cf Sonya and Robots

    题目网址点击打开链接 题目意思是给你一个序列,要从左边数起第一个a的位置要在从右边数起第一个b的位置的前面,让你求(a,b)这样的一对数的种数是多少. 序列里的每个数都可以和他后面的全部数组成(a,b ...

  5. CF #371 (Div. 2) C、map标记

    1.CF #371 (Div. 2)   C. Sonya and Queries  map应用,也可用trie 2.总结:一开始直接用数组遍历,果断T了一发 题意:t个数,奇变1,偶变0,然后与问的 ...

  6. 27.CF1004F Sonya and Bitwise OR 区间合并线段树

    27.CF1004F Sonya and Bitwise OR 区间合并线段树 个人Limitの线段树题单题解主目录:Limitの线段树题单 题解目录_HeartFireY的博客-CSDN博客 给定序 ...

  7. 『参考』.net CF组件编程(4)——为自定义组件添加工具箱图标!

    前言: 在前三篇的文章中,和大家一起创建了一个用于TCP连接检测的小组件,如果你记不得了,可以通过以下链接去回顾一下: 『参考』.net CF组件编程(1)--基础之后 『参考』.net CF组件编程 ...

  8. OC对象 vs CF对象

    2019独角兽企业重金招聘Python工程师标准>>> OC对象 vs CF对象 在ARC场景下,对象所有权没有转换 使用__bridge关键字即可实现CF对象和OC对象之间的自由转 ...

  9. CF 990A. Commentary Boxes【数学/模拟】

    [链接]:CF [题意]:对于一个数n,每次加一的代价是a,每次减一的代价是b,求被m整除时的最小代价. [分析]:分情况讨论,自己多举几个栗子. [代码]: #include<cstdio&g ...

最新文章

  1. SQL基础学习总结:3(select语句基础算术运算符比较运算符)
  2. 数据分析之机器学习(整理笔记)
  3. cocos2dx 学习代码记录
  4. 神策数据CEO桑文锋:精准采集数据,走向智能化分析
  5. 操作XML 报错:根级别上的数据无效 和 给定编码中的字符无效 解决办法
  6. 微信小程序API~GET
  7. springboot项目和云服务器,以及域名的申请和使用(后续持续更新)
  8. Laravel用post提交表单常见的两个错误
  9. 20170808上课笔记
  10. 没网可以用python吗_在没有网络的情况下能自学python吗?
  11. 中外合作有开计算机课吗,探究中外合作办学计算机应用课程建设.doc
  12. java中InvocationHandler 用于实现代理。
  13. 深入了解Java虚拟机
  14. axure文件如何加密_Axure教程:密码可见与不可见的切换设置
  15. [十二省联考2019]希望
  16. 工商数据采集的10个经典方法
  17. java.lang.IllegalStateException: response alrea...
  18. 关于CCNP 642-813交换题库的问题
  19. python是一种代表简单主义思想的语言_python区别于其他语言的优势是什么
  20. 用计算机自动写作文,电脑写一篇作文用说明方法

热门文章

  1. 【雅思】金山词霸-单词学习(41-80)
  2. uboot中LCD驱动修改
  3. math_@多元函数求导@全微分@偏导数@复合偏导
  4. java程序员进阶必读书单
  5. linux 通过命令行打印本机IP
  6. 10-3-查看文章详情
  7. 如何设置自定义任务栏图标_轻松自定义Windows 7任务栏图标
  8. Spring Boot Shiro权限管理
  9. Navicat服务器间的数据库迁移
  10. 编写shell脚本运行python文件