Flowers

Time Limit:2000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u

Description

As is known to all, the blooming time and duration varies between different kinds of flowers. Now there is a garden planted full of flowers. The gardener wants to know how many flowers will bloom in the garden in a specific time. But there are too many flowers in the garden, so he wants you to help him.
 

Input

The first line contains a single integer t (1 <= t <= 10), the number of test cases. 
For each case, the first line contains two integer N and M, where N (1 <= N <= 10^5) is the number of flowers, and M (1 <= M <= 10^5) is the query times. 
In the next N lines, each line contains two integer S i and T i (1 <= S i <= T i <= 10^9), means i-th flower will be blooming at time [S i, T i].
In the next M lines, each line contains an integer T i, means the time of i-th query. 
 

Output

For each case, output the case number as shown and then print M lines. Each line contains an integer, meaning the number of blooming flowers. 
Sample outputs are available for more details. 
 

Sample Input

2
1 1
5 10
4
2 3
1 4
4 8
1
4
6
 

Sample Output

Case #1:
0
Case #2:
1
2
1
 #include <stdio.h>
#include <string.h>
#include <algorithm>
using namespace std;
int main()
{
int T;
int i,j;
int n,m,ca=;
int l[],r[];
scanf("%d",&T);
while(T--)
{
scanf("%d %d",&n,&m);
for(i=;i<=n;i++)
scanf("%d %d",&l[i],&r[i]);
sort(l+,l+n+);
sort(r+,r+n+);
printf("Case #%d:\n",ca);ca++;
for(i=;i<=m;i++)
{
int x,y,z;
scanf("%d",&z);
x=upper_bound(l+,l+n+,z)-(l+);
y=upper_bound(r+,r+n+,z-)-(r+);
printf("%d\n",x-y);
}
}
return ;
}

2012 #3 Flowers的更多相关文章

  1. HDU 4325 Flowers(树状数组)

    Flowers Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Sub ...

  2. (线段树 区间运算求点)Flowers -- hdu -- 4325

    http://acm.hdu.edu.cn/showproblem.php?pid=4325 Flowers Time Limit: 4000/2000 MS (Java/Others)    Mem ...

  3. NC24325 [USACO 2012 Mar S]Flowerpot

    NC24325 [USACO 2012 Mar S]Flowerpot 题目 题目描述 Farmer John has been having trouble making his plants gr ...

  4. Windows server 2012 添加中文语言包(英文转为中文)(离线)

    Windows server 2012 添加中文语言包(英文转为中文)(离线) 相关资料: 公司环境:亚马孙aws虚拟机 英文版Windows2012 中文SQL Server2012安装包,需要安装 ...

  5. Windows Server 2012 NIC Teaming介绍及注意事项

    Windows Server 2012 NIC Teaming介绍及注意事项 转载自:http://www.it165.net/os/html/201303/4799.html Windows Ser ...

  6. 1.初始Windows Server 2012 R2 Hyper-V + 系统安装详细

    干啥的?现在企业服务器都是分开的,比如图片服务器,数据库服务器,redis服务器等等,或多或少一个网站都会用到多个服务器,而服务器的成本很高,要是动不动采购几十台,公司绝对吃不消的,于是虚拟化技术出来 ...

  7. 0.Win8.1,Win10,Windows Server 2012 安装 Net Framework 3.5

    后期会在博客首发更新:http://dnt.dkill.net 网站部署之~Windows Server | 本地部署:http://www.cnblogs.com/dunitian/p/482280 ...

  8. windows 2012 r2 can't find kb2919355

    问题   解决: 1.手动安装了 Windows8.1-KB2919442-x64 2.手动下载 KB2919355 更新成功     Turns out to have been a result ...

  9. Windows Server 2012 磁盘管理之 简单卷、跨区卷、带区卷、镜像卷和RAID-5卷

    今天给客户配置故障转移群集,在Windows Server 2012 R2的系统上,通过iSCSI连接上DELL的SAN存储后,在磁盘管理里面发现可以新建 简单卷.跨区卷.带区卷.镜像卷.RAID-5 ...

随机推荐

  1. copyallwaterdata

    if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[copyallwaterdata]') and OBJECT ...

  2. shell 加减乘除

    #!/bin/basha=$1b=$2echo a+b=$(($a+$b))echo a-b=$(($a-$b))echo a*b=$(($a*$b))echo a/b=$(($a/$b))echo ...

  3. 在Javaweb中使用Scala

    Java 是一门比较优秀的编程语言, 其最大功劳是建立非常繁荣的JVM平台生态.不过 Java 语法比较麻烦,写过 C, Python 的人总是想使用简洁的语法,又希望利用上 Java 平台的强大,因 ...

  4. 【python cookbook】【字符串与文本】3.利用shell通配符做字符串匹配

    问题:当工作在Linux shell下时,使用常见的通配符模式(即,*.py.Dat[0-9]*.csv等)来对文本做匹配 解决方案:fnmatch模块提供的两个函数fnmatch().fnmatch ...

  5. 161025、java提高篇之关键字static

    一. static代表着什么 在Java中并不存在全局变量的概念,但是我们可以通过static来实现一个"伪全局"的概念,在Java中static表示"全局"或 ...

  6. Java的多线程+Socket 后台 Ver 2.0

    package com.wulala; import java.io.IOException;import java.net.ServerSocket;import java.net.Socket; ...

  7. HTML5与移动端Web

    概述 HTML5 提供了很多新的功能,主要有: 新的 HTML 元素,例如 section, nav, header, footer, article 等 用于绘画的 Canvas 元素 用于多媒体播 ...

  8. iOS中 项目开发易错知识点总结

    点击return取消textView 的响应者 - (BOOL)textFieldShouldReturn:(UITextField *)textField { [_contactTextFiled  ...

  9. Linux设置FQDN

    FQDN是Fully Qualified Domain Name的缩写, 含义是完整的域名. 例如, 一台机器主机名(hostname)是www, 域后缀(domain)是example.com, 那 ...

  10. Shipyard安装、使用

    Shipyard使用Citadel集群管理工具包,简化对横跨多个主机的Docker容器集群进行管理.通过Web用户界面,你可以大致浏览相关信息,比如你的容器在使用多少处理器和内存资源.在运行哪些容器, ...