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. Docker配置远程访问

    近来学习Docker部署微服务,需要配置Docker的远程访问,由于实际环境和学习资料有出入,尝试着根据网上搜索的一些相关资料进行配置,未能成功.最终通过自己摸索,成功配置Docker远程访问.现和大 ...

  2. nginx各版本全自动编译安装脚本

    #!/bin/bash #作者:星云法师(头条号:西西图图---专注美食领域的研究) #环境:centos7,如果是其它的系统可以相应做调整.#--------选择安装方式,网络晚装还是本地安装--- ...

  3. Windows程序设计--(二)Unicode 简介

    2.2 宽字符和C语言 2.2.2 更宽的字符 在C语言中的宽字符正是基于short型数据的, 这一数据类型在头文件WCHAR.H中的定义为: typedef unsigned short wchar ...

  4. 如何用CSS定义一个动画?

    <style type="text/css"> div{ width:100px;height: 100px; animation: carton 5s; backgr ...

  5. JS继承——原型链

    许多OO语言支持两种继承:接口继承和实现继承.ECMAScript只支持实现继承,且继承实现主要依赖原型链实现. 原型链 基本思想:利用原型让一个引用类型继承另一个引用类型的属性和方法. 构造函数.原 ...

  6. MySQL 授权用户 ; 存储过程的DEFINER; 命令分隔符DELIMITER

    最近项目中遇到有人使用DEFINER这样的关键字,找了半天没有怎么理解这个意思.以为是限制谁使用这个存储过程,后来测试发现并不是这样. 搜索网上发现很多说法都不正确.看到一篇博客,做了如下介绍,才有所 ...

  7. 2019-1-25-WPF-ListBox-的选择

    title author date CreateTime categories WPF ListBox 的选择 lindexi 2019-01-25 21:43:17 +0800 2018-2-13 ...

  8. mongodb使用简介

    mongodb简介 在使用nodejs时候,需要存储一些简单json数据的情况下,很多人会推荐使用mongodb.mongodb是一个文档型数据库,在 sql 中,数据层级是:数据库(db) -> ...

  9. springboot dubbo logback shutdownhook简单总结

      public class Test { public static void main(String[] args){ System.out.println("1: Main start ...

  10. Mongodb Capped Collection集合

    MongoDB 固定集合(Capped Collections)是性能出色且有着固定大小的集合,对于大小固定,我们可以想象其就像一个环形队列,当集合空间用完后,再插入的元素就会覆盖最初始的头部的元素! ...