Bus Stop

题目描述

In a rural village in Thailand, there is a long, straight, road with houses scattered along it.

(We can picture the road as a long line segment, with an eastern endpoint and a western endpoint.) The Thai government is planning to set up bus stops on this road in such a way that every house is within ten kilometers of one of the stops. What is the minimum number of stops the government need to set up to satisfy the requirement?

输入

The first line contains a single integer m representing the number of the test cases. Eachtest case consists of the following two lines:

The first line contains a single integer n representing the number of houses on the road, where 0 ≤ n ≤ 2,000,000.

The second line contains n integers h1 h2 … hn representing the locations of the houses in kilometers as measured from the start of the road, where 0 ≤ hi ≤ 90,000,000. That is, the first house is h1 kilometers away from the start of the road, the second house is h2 kilometers

away from the start of the road, and so on. You may assume that hi ’s are sorted in ascending order, e.g., h1 ≤ h2 ≤ h3 ≤ … ≤ hn .

输出

For each test case, print out in a single line the minimum number of bus stops that satisfy the requirement.

样例输入

2
5
1 2 3 200 210
4
10 30 80 200

样例输出

2
3

题意

建立公交站 每个站的范围是10 给你一些位置问需要多少个公交站

题解

水题 从头遍历 记录上一个站的位置 如果不在上一个站范围内 就重建一个

代码

#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for(int i=a;i<n;i++)
#define scac(x) scanf("%c",&x)
#define sca(x) scanf("%d",&x)
#define sca2(x,y) scanf("%d%d",&x,&y)
#define sca3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define scl(x) scanf("%lld",&x)
#define scl2(x,y) scanf("%lld%lld",&x,&y)
#define scl3(x,y,z) scanf("%lld%lld%lld",&x,&y,&z)
#define pri(x) printf("%d\n",x)
#define pri2(x,y) printf("%d %d\n",x,y)
#define pri3(x,y,z) printf("%d %d %d\n",x,y,z)
#define prl(x) printf("%lld\n",x)
#define prl2(x,y) printf("%lld %lld\n",x,y)
#define prl3(x,y,z) printf("%lld %lld %lld\n",x,y,z)
#define ll long long
#define LL long long
#define pb push_back
#define mp make_pair
#define P pair<int,int>
#define PLL pair<ll,ll>
#define PI acos(1.0)
#define eps 1e-6
#define inf 1e17
#define INF 0x3f3f3f3f
#define N 5005
const int maxn = 2000005;
int t,n;
int a[maxn];
int main()
{
sca(t);
while(t--)
{
sca(n);
rep(i,0,n)
sca(a[i]);
int mx = -100;
int ans = 0;
rep(i,0,n)
{
if(mx + 10 < a[i])
{
mx = a[i] + 10;
ans++;
}
}
pri(ans);
}
}

upc组队赛14 Bus stop【签到水】的更多相关文章

  1. upc组队赛16 Melody【签到水】

    Melody 题目描述 YellowStar is versatile. One day he writes a melody A = [A1, ..., AN ], and he has a sta ...

  2. upc组队赛14 As rich as Crassus【扩展中国剩余定理】

    As rich as Crassus 题目链接 题目描述 Crassus, the richest man in the world, invested some of his money with ...

  3. upc组队赛14 Floating-Point Hazard【求导】

    Floating-Point Hazard 题目描述 Given the value of low, high you will have to find the value of the follo ...

  4. upc组队赛14 Communication【并查集+floyd /Tarjan】

    Communication 题目描述 The Ministry of Communication has an extremely wonderful message system, designed ...

  5. upc组队赛14 Evolution Game【dp】

    Evolution Game 题目描述 In the fantasy world of ICPC there are magical beasts. As they grow, these beast ...

  6. upc组队赛3 Chaarshanbegaan at Cafebazaar

    Chaarshanbegaan at Cafebazaar 题目链接 http://icpc.upc.edu.cn/problem.php?cid=1618&pid=1 题目描述 Chaars ...

  7. upc组队赛3 Iranian ChamPions Cup

    Iranian ChamPions Cup 题目描述 The Iranian ChamPions Cup (ICPC), the most prestigious football league in ...

  8. codeforces 711A A. Bus to Udayland(水题)

    题目链接: A. Bus to Udayland 题意: 找一对空位坐下来,水; 思路: AC代码: #include <iostream> #include <cstdio> ...

  9. upc组队赛1 不存在的泳池【GCD】

    不存在的泳池 题目描述 小w是云南中医学院的同学,有一天他看到了学校的百度百科介绍: 截止到2014年5月,云南中医学院图书馆纸本藏书74.8457万册,纸质期刊388种,馆藏线装古籍图书1.8万册, ...

随机推荐

  1. nginx配置多个server,搭建多个站点

    今天域名备案终于成功了,赶紧进行了域名的绑定,在配置vhosts的时候发现了一个default_server 字段,对于这个字段之前没有接触过,后来查了一下,其实是这样的 当用户在浏览器中输入相关域名 ...

  2. 19、NumPy——线性代数

    NumPy 线性代数 NumPy 提供了线性代数函数库 linalg,该库包含了线性代数所需的所有功能,可以看看下面的说明: 函数 描述 dot 两个数组的点积,即元素对应相乘. vdot 两个向量的 ...

  3. 5、numpy——切片和索引

    1.一维数组 1.1 一维数组很简单,基本和列表一致.ndarray 数组可以基于 0 - n 的下标进行索引. 切片对象可以通过内置的 slice 函数,并设置 start, stop 及 step ...

  4. NGUI的滚动条的制作(scroll bar script)

    一,我们添加一个sprite,添加一个box collider,然后添加一个scroll bar script,我们来看看scroll bar script的属性 看到background和forgr ...

  5. k3 cloud套打模板中出现单元格数据为空的情况,及无法正确的选择数据源

    解决办法: 找到右边的导航树,点击数据表格选中,然后到左边点击右键,绑定数据

  6. linux性能相关的各个环节

  7. Jmeter —— Test Fragment (测试片段)

    Test Fragment(测试片段) 1.    概念 JMeter中的Test Fragent:是控制器上一种特殊的线程组:它在测试树上与线程组处于同一个层级.但是使用的时候需要和Include ...

  8. Java中的两种异常类型及其区别?

    Java中的两种异常类型是什么?他们有什么区别? Throwable包含了错误(Error)和异常(Excetion两类) Exception又包含了运行时异常(RuntimeException, 又 ...

  9. hive之调优

    1.简单的查询,就是只是select,不带count,sum,group by这样的,都不走map/reduce,直接读取hdfs文件进行filter过滤,即尽量让fetch task(当开启一个Fe ...

  10. 安装Windows与CentOS双系统

    1.安装Windows系统 安装过程除了分区时要预留出部分空间来安装CentOS之外,其它操作与正常安装一样. 2.安装CentOS系统 使用光盘引导安装,因安装为服务器版,建议选择无界面,最小化安装 ...