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. 【学习总结】Python-3-字符串函数split()的妙用

    参考: 菜鸟教程-Python3-Python字符串-split() 语法: str.split(str="", num=string.count(str)) 参数 str -- ...

  2. web前端之html基础知识初级

    html 基础标签 单标签 1.注释标签: ctrl+/ 换行标签: 横线标签: 标题标签: 段落标签: 表示强调标签: 文字 属性:文字加颜色 color:改变文字颜色 size:改文字大小属性 例 ...

  3. ToolStripComboBox 绑定数据

    //添加ComboBox tcbbQueryCondition.ComboBox.DataSource = RelationalOperators.GetAllOperators(); tcbbQue ...

  4. 1.ireport基本使用

    1. 2.

  5. fputc, fputs, putc, putchar, puts - 输出字符和字符串

    总览 (SYNOPSIS) #include <stdio.h> int fputc(int c, FILE *stream); int fputs(const char *s, FILE ...

  6. windows10安装nodejs 10和express 4

    最进做一个个人博客系统,前端用到了semanticUI,但是要使用npm工具包,所以需要安装nodejs,nodejs自带npm 下载 去官网下载自己系统对应的版本,我的是windows:下载 可以在 ...

  7. python常用函数 L

    lstrip(str) 删除字符串左边的字符,支持传入参数. 例子: ljust(int) 格式化字符串,左对齐,支持传入填充值. 例子: loads(json) 将json字符串转换为dict. 例 ...

  8. wait()和sleep()、sleep()和yield()的区别

    wait()和sleep()的区别主要表现在一下几个方面: 原理不同.sleep()方法是Thread类的静态方法,是线程用来控制自身流程的.它会使线程暂停执行一段时间,把执行机会让给其他线程,等到时 ...

  9. 在CNN上增加一层CAM告诉你CNN到底关注什么

    Cam(Class Activation Mapping)是一个很有意思的算法,他能够将神经网络到底在关注什么可视化的表现出来.但同时它的实现却又如此简介,相比NIN,googLenet这些使用GAP ...

  10. java 方法返回多个值

    package java03; /* * 一个方法可以有0,1或者多个参数,但是返回值只能有0或者1个返回值,不能有多个返回值 * 但是如果希望有多个返回值,应该怎么办? * 答:使用数组作为返回值类 ...