HDU 4268

简介: 1 #include 2 #include 3 #include 4 #include 5 #include 6 using namespace std; 7 8 const int N=100010; 9 struct Node{ 10 ...
 1 #include <iostream>
 2 #include <stdio.h>
 3 #include <string.h>
 4 #include <algorithm>
 5 #include <set>
 6 using namespace std;
 7 
 8 const int N=100010;
 9 struct Node{
10     int x,y,type;
11     bool operator<(const Node &b) const {
12         if(x!=b.x) return x<b.x;
13         if(y!=b.y) return y<b.y;
14         return type>b.type;
15     }
16 };
17 
18 typedef multiset<int> SET;
19 typedef multiset<int>::iterator IT;
20 
21 
22 Node a[N<<1];
23 SET S;
24 const int Inf=0x80000000;
25 int T,n;
26 
27 
28 int main() {
29     scanf("%d",&T);
30     while(T--) {
31         scanf("%d",&n);
32         for(int i=0;i<2*n;i++) scanf("%d%d",&a[i].x,&a[i].y);
33         for(int i=0;i<n;i++) a[i].type=0;
34         for(int i=n;i<n<<1;i++) a[i].type=1;
35         sort(a,a+2*n);
36         S.clear();
37         int ans=0;
38         for(int i=0;i<2*n;i++) {
39             if(a[i].type==1) S.insert(a[i].y);
40             else {
41                 if(!S.empty()){
42                     if(*S.begin()<=a[i].y){
43                         IT it=S.upper_bound(a[i].y);
44                         it--;
45                         ans++;
46                         S.erase(it);
47                     }
48                 }
49             }
50         }
51         printf("%d\n",ans);
52     }
53     return 0;
54 }

 

目录
相关文章
|
11月前
|
Java 测试技术
hdu 1228 A + B
hdu 1228 A + B
42 0
|
11月前
|
Java 文件存储
hdu1128 Self Numbers
hdu1128 Self Numbers
34 0
HDU 2549 壮志难酬
壮志难酬 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 12541    Accepted Submission(s): 4166 Problem Description 话说MCA山上各路豪杰均出山抗敌,去年曾在江湖威名显赫的,江湖人称的甘露也不甘示弱,“天将降大任于斯人也,必先劳其筋骨,饿其体肤,空乏其身”他说。
1025 0
|
机器学习/深度学习
|
定位技术
hdu 4771 Stealing Harry Potter's Precious
点击打开链接 题意:题目给定一个n*m的地图,地图有一个起点标记为'@',还有'#'表示不能够走的,'.'表示可以走。给定k个点,问从起点开始把这k个点走过去的最小步数。
788 0
hdu 1754 I Hate It
点击打开链接hdu 1754 思路: 线段树+单点更新 分析: 1 线段树的水题 代码: /************************************************ * By: chenguolin ...
782 0
|
存储
hdu 2203 亲和串
点击打开链接hdu 2203 思路:kmp 分析: 1 题目要求的是给定字符串s1 和 s2,问s1能否通过移位得到使得s2包含在s1里面。
816 0