hdu4907:http://acm.hdu.edu.cn/showproblem.php?pid=4907

题意:中文题。

题解:这一道水题,自己调了很久,并且没有注意到序列可能是乱序的,wa了好几次。我的做法就是,把间距大于=2的数的下标放进set,然后查询的时候,lower_bond一下,找到开始的下标,然后在set中找到第一个间距的下标,即可,注意要处理好边界问题。

 #include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<set>
using namespace std;
const int N=2e5+;
int a[N],n,m,t;
int main(){
int cas;
scanf("%d",&cas);
while(cas--){
scanf("%d%d",&n,&m);
memset(a,,sizeof(a));
set<int>Q;
for(int i=;i<=n;i++){
scanf("%d",&a[i]);
}
sort(a+,a+n+);
for(int i=;i<=n;i++){
if(i>)
if(a[i]-a[i-]>=)
Q.insert(i-);
}
for(int i=;i<=m;i++){
scanf("%d",&t);
if(t>a[n]+)printf("%d\n",t);
else if(t<a[])printf("%d\n",t);
else{
int temp=lower_bound(a+,a+n+,t)-a;
if(a[temp]>t&&temp>)temp--;
set<int>::iterator it=Q.lower_bound(temp);
if(it==Q.end())
printf("%d\n",a[n]+);
else{
printf("%d\n",max(a[(*it)]+,t));
}
}
}
}
}

Task schedule的更多相关文章

  1. HDU 3572 Task Schedule(拆点+最大流dinic)

    Task Schedule Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) To ...

  2. Task schedule 分类: 比赛 HDU 查找 2015-08-08 16:00 2人阅读 评论(0) 收藏

    Task schedule Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total ...

  3. HDU3572 Task Schedule 【最大流】

    Task Schedule Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) To ...

  4. HDU4907——Task schedule(BestCoder Round #3)

    Task schedule Description有一台机器,并且给你这台机器的工作表,工作表上有n个任务,机器在ti时间执行第i个任务,1秒即可完成1个任务.有m个询问,每个询问有一个数字q,表示如 ...

  5. hdu 3572 Task Schedule

    Task Schedule 题意:有N个任务,M台机器.每一个任务给S,P,E分别表示该任务的(最早开始)开始时间,持续时间和(最晚)结束时间:问每一个任务是否能在预定的时间区间内完成: 注:每一个任 ...

  6. hdoj 3572 Task Schedule【建立超级源点超级汇点】

    Task Schedule Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Tot ...

  7. hdu 3572 Task Schedule (dinic算法)

    pid=3572">Task Schedule Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 ...

  8. SharePoint 2013 Backup Farm Automatically With a Powershell and Windows Task Schedule

    In this post,I will show you SharePoint 2013 How to Backup Farm Automatically with a PowerShell and ...

  9. hdu 3572 Task Schedule(最大流&amp;&amp;建图经典&amp;&amp;dinic)

    Task Schedule Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) To ...

  10. POJ 3553 Task schedule【拓扑排序 + 优先队列 / 贪心】

    Task schedule Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 515 Accepted: 309 Special J ...

随机推荐

  1. strace使用详解(转) 分类: shell ubuntu 2014-11-27 17:48 134人阅读 评论(0) 收藏

    (一) strace 命令    用途:打印 STREAMS 跟踪消息. 语法:strace [ mid sid level ] ... 描述:没有参数的 strace 命令将所有的驱动程序和模块中的 ...

  2. [RxJS] Transformation operator: repeat

    Operator repeat() is somewhat similar to retry(), but is not for handling operators. In this lesson ...

  3. 数缘社区上对libtom的介绍,贴过来先

    http://blog.csdn.net/songlingrebecca/article/details/5879154 基于Bit位运算的C语言库分析及其应用 1 LibTomproject的简要介 ...

  4. mysql 参数:[read_buffer_size] [sort_buffer_size] [read_rnd_buffer_size] [tmp_table_size]---图解

    http://imysql.cn/2008_09_27_deep_into_mysql_sort_buffer http://my.oschina.net/realfighter/blog/36442 ...

  5. javascript-for-loop-example--reference

    We hear a lot about loops, especially for loops. So what, in fact, are they? They’re just pieces of ...

  6. shell入门之变量测试 分类: 学习笔记 linux ubuntu 2015-07-10 15:49 31人阅读 评论(0) 收藏

    格式:test 测试条件 字符串测试: 注意空格: test str1 == str2 测试字符串是否相等 test str1 != str2 测试字符串是否不相等 test str1 测试字符串是否 ...

  7. java 基本类型和包装类的比较

    public class BoxingTest { @Test public void test1(){ String a = new String("1"); String b ...

  8. Android常用第三方框架

    1.volley (截击) 项目地址 https://github.com/smanikandan14/Volley-demo (1)  JSON,图像等的异步下载: (2)  网络请求的排序(sch ...

  9. [转载]CentOS6.4+Mono3.0.7+Jexus5.2.5

    本文章来自互联网,但是本人已经在VM虚拟机里面测试成功,所以分享给大家 1.更新 yum -y update 2.安装Mono源码安装需要的库 yum -y install gcc gcc-c++ a ...

  10. 【转】 iOS KVO KVC

    原文: http://www.cocoachina.com/industry/20140224/7866.html Key Value Coding Key Value Coding是cocoa的一个 ...