题目大意:有n个人,每个人都有三个物品,排名分别为a[ i ],b[ i ],b[ i ],现在要删掉其中的一些人

如果一个人x的三个物品的排名为a[ x ],b[ x ],b[ x ],若存在另一个人y物品排名为a[ y ],b[ y ],b[ y ],

且a[ y ]<a[ x ] && b[ y ]<b[ x ]  && c[ y ]<c[ x ],则删掉x,问你最后剩下多少人。

思路:一开始肯定要按一个物品的排名进行排序,然后就三个人想了半小时没想出来,感觉要用数据

结构,但是不知道怎么写,看来还是对线段树不太了解!!!!

首先,我们按物品a的排名排序,然后我们用b物品的排名建立线段树维护物品c的最小值即可。

 #include<bits/stdc++.h>
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
using namespace std;
const int N=1e5+;
const int inf=0x3f3f3f3f;
int mn[N<<],n;
struct node
{
int a,b,c;
bool operator <(const node &t)const
{
return a<t.a;
}
}w[N];
void updata(int x,int v,int l,int r,int rt)
{
if(l==r)
{
mn[rt]=min(mn[rt],v);
return;
}
int m=(l+r)>>;
if(x<=m) updata(x,v,lson);
else updata(x,v,rson);
mn[rt]=min(mn[rt<<],mn[rt<<|]);
}
int query(int L,int R,int l,int r,int rt)
{
if(l>=L && r<=R) return mn[rt];
int m=(l+r)>>;
int ans=inf;
if(L<=m) ans=min(ans,query(L,R,lson));
if(R>m) ans=min(ans,query(L,R,rson));
return ans;
}
int main()
{
int T; cin>>T;
while(T--)
{
cin>>n;
for(int i=;i<n;i++) scanf("%d%d%d",&w[i].a,&w[i].b,&w[i].c);
sort(w,w+n);
memset(mn,inf,sizeof(mn));
int ans=;
for(int i=;i<n;i++)
{
int g=query(,w[i].b,,n,);
if(g>w[i].c) ans++;
updata(w[i].b,w[i].c,,n,);
}
printf("%d\n",ans);
}
return ;
}

最新文章

  1. 2017年1月4日 星期三 --出埃及记 Exodus 21:30
  2. uvm - driver
  3. 如何运用boolean跳出循环
  4. Java 9终于要包含Jigsaw项目了
  5. android自定义activity
  6. 【C语言入门教程】1.1 基本程序结构
  7. String类中一些的方法的应用
  8. Knockout 新版应用开发教程之Observable Arrays
  9. WPF中ListView如何改变选中条背景颜色
  10. C#制作简易屏保(转)
  11. UnitOfWork实战
  12. Linux 基本命令-----常用操作分类
  13. 深度搜索DFS-Lake Counting(POJ NO.2386)
  14. Centos7源码安装mariadb
  15. p86商空间也是Banach空间
  16. setting.xml配置文件
  17. (原)android系统下绑定Server的时候报MainActivity has leaked ServiceConnection的错误
  18. android studio 引用远程仓库下载慢(JCenter下载慢)的办法
  19. 零开始:NetCore项目权限管理系统:登录授权
  20. Spring源码分析(三)容器核心类

热门文章

  1. webuploader
  2. mongoDB - 日常操作三
  3. Linux - 网络检测
  4. Redis 主从 keepalived高可用 实现 VIP 自动漂移
  5. CF1066D Boxes Packing
  6. org.apache.phoenix.exception.PhoenixIOException: SYSTEM:CATALOG
  7. JS浮点数运算Bug的解决办法
  8. 用conda管理Python包
  9. Libevent源码分析—event_add()
  10. python调用win32com.client的GetObject查找进程信息及服务信息