Problem Description
John has several lines. The lines are covered on the X axis. Let A is a point which is covered by the most lines. John wants to know how many lines cover A.
 
Input
The first line contains a single integer T(1≤T≤100)(the data for N>100 less than 11 cases),indicating the number of test cases.
Each test case begins with an integer N(1≤N≤105),indicating the number of lines.
Next N lines contains two integers Xi and Yi(1≤Xi≤Yi≤109),describing a line.
 
Output
For each case, output an integer means how many lines cover A.
 
Sample Input
2
5
1 2
2 2
2 4
3 4
5 1000
5
1 1
2 2
3 3
4 4
5 5
 
Sample Output
3
1
 
 
题目大意:
给你几个区间,然后给这区间间的点染色
求最染色最多的点 染了多少色
 
分析:
 
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<iostream>
#include<string.h>
#include<algorithm>
#include<vector>
using namespace std;
#define N 1100000 struct node
{
int x,y;
}a[N];
int f[N],p[N]; int main()
{
int T,n,i;
scanf("%d",&T);
while(T--)
{
int k=;
memset(a,,sizeof(a));
memset(f,,sizeof(f));
memset(p,,sizeof(p));
scanf("%d",&n);
for(i=;i<n;i++)
{
scanf("%d %d",&a[i].x,&a[i].y);
p[k++]=a[i].x;
p[k++]=a[i].y;
}
sort(p,p+k);
int len=unique(p,p+k)-p;
int Max=;
for(i=;i<n;i++)
{
int u=lower_bound(p,p+len,a[i].x)-p;
int v=lower_bound(p,p+len,a[i].y)-p;
f[u]++;
f[v+]--;
Max=max(Max,v+);
}
int ans=,b=;
for(i=;i<=Max;i++)
{
ans+=f[i];
b=max(b,ans);
}
printf("%d\n",b);
}
return ;
}

lines-HDU5124(区间处理 +离散化)的更多相关文章

  1. POJ-2528 Mayor's posters (线段树区间更新+离散化)

    题目分析:线段树区间更新+离散化 代码如下: # include<iostream> # include<cstdio> # include<queue> # in ...

  2. POJ 2528 Mayor's posters (线段树+区间覆盖+离散化)

    题意: 一共有n张海报, 按次序贴在墙上, 后贴的海报可以覆盖先贴的海报, 问一共有多少种海报出现过. 题解: 因为长度最大可以达到1e7, 但是最多只有2e4的区间个数,并且最后只是统计能看见的不同 ...

  3. HDU5124:lines(线段树+离散化)或(离散化思想)

    http://acm.hdu.edu.cn/showproblem.php?pid=5124 Problem Description John has several lines. The lines ...

  4. POJ 2528 Mayor's posters(线段树/区间更新 离散化)

    题目链接: 传送门 Mayor's posters Time Limit: 1000MS     Memory Limit: 65536K Description The citizens of By ...

  5. POJ 2528 Mayor's posters(线段树区间染色+离散化或倒序更新)

    Mayor's posters Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 59239   Accepted: 17157 ...

  6. poj-----(2528)Mayor's posters(线段树区间更新及区间统计+离散化)

    Mayor's posters Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 43507   Accepted: 12693 ...

  7. POJ2528:Mayor's posters(线段树区间更新+离散化)

    Description The citizens of Bytetown, AB, could not stand that the candidates in the mayoral electio ...

  8. Educational Codeforces Round 10 D. Nested Segments 【树状数组区间更新 + 离散化 + stl】

    任意门:http://codeforces.com/contest/652/problem/D D. Nested Segments time limit per test 2 seconds mem ...

  9. POJ-2528 Mayor's posters(线段树区间更新+离散化)

    http://poj.org/problem?id=2528 https://www.luogu.org/problem/UVA10587 Description The citizens of By ...

  10. hiho一下21周 线段树的区间修改 离散化

    离散化 时间限制:10000ms 单点时限:1000ms 内存限制:256MB 描述 小Hi和小Ho在回国之后,重新过起了朝7晚5的学生生活,当然了,他们还是在一直学习着各种算法~ 这天小Hi和小Ho ...

随机推荐

  1. listBox 搜索左右移动

    <td align="left" width="50%"> 查询:<asp:TextBox ID="SacffSearch" ...

  2. Myeclipse 6.0代码

    import java.util.*; import java.io.*; public class bbs { private static final String LL = "Deco ...

  3. Android 中保存数据到文件中

    1.在安卓开发中,会遇到保存数据到手机中以及从手机中获取数据的情况 /** * 把数据存放到手机内存中 * * @param number * @param password * @return */ ...

  4. 简单探讨弹性布局flex

    css 弹性布局: 盒子模型: box-sizing属性1.content-box 正常的普通的盒子模型用padding和border会使盒子变大:(向外扩张)2.border-box 盒子模型,pa ...

  5. PPTP的搭建

    一.准备 1.检查是否支持pptp modprobe ppp-compress-18 && echo yes yes支持 2.是否开启tun cat /dev/net/tun 返回ca ...

  6. cron on Centos

    1. crond.service 2. configuration 2.0 format # Example of job definition: # .---------------- minute ...

  7. clusterdb - 对一个PostgreSQL数据库进行建簇

    SYNOPSIS clusterdb [ connection-option...] [ --table | -t table] [ dbname] clusterdb [ connection-op ...

  8. CAD参数绘制块引用对象(com接口)

    主要用到函数说明: _DMxDrawX::DrawBlockReference 绘制块引用对象.详细说明如下: 参数 说明 DOUBLE dPosX 插入点的X坐标 DOUBLE dPosY 插入点的 ...

  9. CAD参数绘制实心圆弧填充(网页版)

    js中实现代码说明: function DrawPathToHatch1() { //把路径的开始位置移动指定的点 //参数一为点的X坐标 ,参数二为点的Y坐标,参数三为该点处开始宽度,对Polyli ...

  10. 根据截至日期格式获取倒计时&&时间戳转日期格式

    //时间戳转日期格式,传入时间戳必须为数字类型function currentDate(shijianchuo) { var date = new Date(shijianchuo); var y = ...