题目链接:http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=26806

题目大意:略

题目思路:前缀和与离散化

可用线段树做,但是前缀和更简单

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <stack>
#include <cctype>
#include <queue>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <climits>
#define lson root<<1,l,mid
#define rson root<<1|1,mid+1,r
#define fi first
#define se second
#define ping(x,y) ((x-y)*(x-y))
#define mst(x,y) memset(x,y,sizeof(x))
#define Min(x,y) (x<y?x:y)
#define Max(x,y) (x>y?x:y)
using namespace std;
#define gamma 0.5772156649015328606065120 //欧拉常数
#define MOD 100000007
#define inf 0x3f3f3f3f
#define N 50010
#define maxn 10001000
typedef long long LL;
typedef pair<int,int> PII; int n,m,a[N<<],res[N<<];
PII p[N]; int main()
{
int i,x,y,v,group,Case=;
//freopen("in.txt","r",stdin);
scanf("%d",&group);
while(group--)
{
mst(res,);
int cnt=;
scanf("%d%d",&n,&m);
for(i=; i<n; ++i)
{
scanf("%d%d",&p[i].fi,&p[i].se);
a[cnt++]=p[i].fi;
a[cnt++]=++p[i].se;
}
stable_sort(a,a+cnt);
cnt=unique(a,a+cnt)-a;
for(i=; i<n; ++i)
{
int l=lower_bound(a,a+cnt,p[i].fi)-a;
int r=lower_bound(a,a+cnt,p[i].se)-a;
++res[l];--res[r];
}
for(i=; i<cnt; ++i)
res[i]+=res[i-];
printf("Case %d:\n",++Case);
for(i=; i<m; ++i)
{
scanf("%d",&x);
int pos=upper_bound(a,a+cnt,x)-a;
printf("%d\n",res[pos-]);
}
}
return ;
}

LightOJ1089的更多相关文章

  1. LightOj1089(求点包含几个线段 + 线段树)

    题目链接 题意:n( n <= 50000 ) 个线段,q ( q <= 50000) 个点,问每个点在几个线段上 线段端点的和询问的点的值都很大,所以必须离散化 第一种解法:先把所有的线 ...

随机推荐

  1. react-native-scrollable-tab-view 实现 TabBar

    1.创建组件 src/components/CustomTabBar/index.js /** * 自定义选项卡 */ import React, {Component} from 'react'; ...

  2. Phalcon 訪问控制列表 ACL(Access Control Lists ACL)

    Phalcon在权限方面通过 Phalcon\Acl 提供了一个轻量级的 ACL(訪问控制列表). Access Control Lists (ACL) 同意系统对用户的訪问权限进行控制,比方同意訪问 ...

  3. 电脑 F键(功能键)的具体作用

    F1:如果你处在一个选定的程序中而需要帮助,那么请按下F1.如果现在不是处在任何程序中,而是处在资源管理器或桌面,那么按下F1就会出现Windows的帮助程序.如果你正在对某个程序进行操作,而想得到W ...

  4. src和href使用总结

    src img 图片 <img src="/img/1.png" alt="1" /> rame iframe 框架集 <iframe src ...

  5. 如何下载PDF?

    IIS MIME类型配置: application/octet-stream

  6. 简体字冯|docker-安装docker私有库

    原创文章,转载请注明出处. 作者:简体字丶冯; QQ:564372931 安装docker 各终端安装docker 教程 菜鸟docker教程 就挺好,本着不重复造轮子的原则就不深入了,自己学习. 如 ...

  7. 编辑HTML代码,批量制作博文清单

    当积累的博文多了,常想制作一个分类文件夹,方便读者阅读.这能够是一个不轻松且枯燥的工作. 以<关于"IT学子成长指导"专栏及文章文件夹>中文件夹的制作为例.介绍我的&q ...

  8. Django学习之raw()方法查询数据

    我们经常有这种需求: 用sql来查询以及写入数据到数据库,Django当然也提供了这种方式,那就是通过raw方法: sql = "select * from blog_blog where ...

  9. centos7下安装mysql5.7和jdk 1.8

    安装mysql5.7 具体安装过程可参见官网:A Quick Guide to Using the MySQL Yum Repository 进入/usr/local/src文件夹. cd /usr/ ...

  10. CentOS 7 安装以及配置桌面环境

    一.安装 GNOME 桌面 1.安装命令: yum groupinstall  "GNOME Desktop" "X Window System" " ...