HDU 4268

 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 }

 

转载于:https://www.cnblogs.com/hxsyl/archive/2012/09/09/2677249.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值