CF B. Sonya and Exhibition
1 second
256 megabytes
standard input
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.
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.
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.
4 3 -3 2 9 16
6
5 2 4 8 11 18 19
5
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相关推荐
- Sonya and Exhibition 【模拟】
题目链接:https://cn.vjudge.net/contest/280309#problem/J 题目描述 Sonya decided to organize an exhibition of ...
- CodeForces - 1004B - Sonya and Exhibition(纯思维题)
题目链接: http://codeforces.com/problemset/problem/1004/B 题目: Sonya decided to organize an exhibition of ...
- 常用技巧 —— 打表规律
[概述] 找规律是一种常见的题型,当给出相关数据后,我们往往可以利用打表的方法,得到大量的数据,然后再寻找规律. 简单来说,打表就是需要对某个范围内的数据进行判断,判断它是否符合某种条件,然后在接下来 ...
- cf Sonya and Robots
题目网址点击打开链接 题目意思是给你一个序列,要从左边数起第一个a的位置要在从右边数起第一个b的位置的前面,让你求(a,b)这样的一对数的种数是多少. 序列里的每个数都可以和他后面的全部数组成(a,b ...
- CF #371 (Div. 2) C、map标记
1.CF #371 (Div. 2) C. Sonya and Queries map应用,也可用trie 2.总结:一开始直接用数组遍历,果断T了一发 题意:t个数,奇变1,偶变0,然后与问的 ...
- 27.CF1004F Sonya and Bitwise OR 区间合并线段树
27.CF1004F Sonya and Bitwise OR 区间合并线段树 个人Limitの线段树题单题解主目录:Limitの线段树题单 题解目录_HeartFireY的博客-CSDN博客 给定序 ...
- 『参考』.net CF组件编程(4)——为自定义组件添加工具箱图标!
前言: 在前三篇的文章中,和大家一起创建了一个用于TCP连接检测的小组件,如果你记不得了,可以通过以下链接去回顾一下: 『参考』.net CF组件编程(1)--基础之后 『参考』.net CF组件编程 ...
- OC对象 vs CF对象
2019独角兽企业重金招聘Python工程师标准>>> OC对象 vs CF对象 在ARC场景下,对象所有权没有转换 使用__bridge关键字即可实现CF对象和OC对象之间的自由转 ...
- CF 990A. Commentary Boxes【数学/模拟】
[链接]:CF [题意]:对于一个数n,每次加一的代价是a,每次减一的代价是b,求被m整除时的最小代价. [分析]:分情况讨论,自己多举几个栗子. [代码]: #include<cstdio&g ...
最新文章
- SQL基础学习总结:3(select语句基础算术运算符比较运算符)
- 数据分析之机器学习(整理笔记)
- cocos2dx 学习代码记录
- 神策数据CEO桑文锋:精准采集数据,走向智能化分析
- 操作XML 报错:根级别上的数据无效 和 给定编码中的字符无效 解决办法
- 微信小程序API~GET
- springboot项目和云服务器,以及域名的申请和使用(后续持续更新)
- Laravel用post提交表单常见的两个错误
- 20170808上课笔记
- 没网可以用python吗_在没有网络的情况下能自学python吗?
- 中外合作有开计算机课吗,探究中外合作办学计算机应用课程建设.doc
- java中InvocationHandler 用于实现代理。
- 深入了解Java虚拟机
- axure文件如何加密_Axure教程:密码可见与不可见的切换设置
- [十二省联考2019]希望
- 工商数据采集的10个经典方法
- java.lang.IllegalStateException: response alrea...
- 关于CCNP 642-813交换题库的问题
- python是一种代表简单主义思想的语言_python区别于其他语言的优势是什么
- 用计算机自动写作文,电脑写一篇作文用说明方法