记录编号 |
512148 |
评测结果 |
AAAAAAAAAAAAAAAAAAAA |
题目名称 |
天天爱射击 |
最终得分 |
100 |
用户昵称 |
梦那边的美好ET |
是否通过 |
通过 |
代码语言 |
C++ |
运行时间 |
15.524 s |
提交时间 |
2018-10-02 00:22:16 |
内存使用 |
54.59 MiB |
显示代码纯文本
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstring>
using namespace std;
int n,m,ans[200010],root[200010],a1,a2,sum=0;
struct mb{int l1,r1,s;}b[200010];
struct tree{int l,r,z;}a[6000010];
inline int maketree(int x,int y){++sum;
int p=sum;
a[p].z=0;
if(x==y)return p;
int mid=(x+y)>>1;
a[p].l=maketree(x,mid);
a[p].r=maketree(mid+1,y);
return p;
}
inline int treein(int k,int x,int y){++sum;
int p=sum;
if(x==y){a[p].z=a[k].z+1;return p;}
int mid=(x+y)>>1;
a[p].l=a[k].l;a[p].r=a[k].r;
if(a1<=mid)a[p].l=treein(a[k].l,x,mid);
else a[p].r=treein(a[k].r,mid+1,y);
a[p].z=a[a[p].l].z+a[a[p].r].z;
return p;
}
inline int treeout(int p,int x,int y,int l1,int r1){
if(l1==x&&r1==y)return a[p].z;
int mid=(x+y)>>1;
if(r1<=mid)return treeout(a[p].l,x,mid,l1,r1);
if(mid<l1)return treeout(a[p].r,mid+1,y,l1,r1);
return treeout(a[p].l,x,mid,l1,mid)+treeout(a[p].r,mid+1,y,mid+1,r1);
}
inline int hs(){
freopen("shooting.in","r",stdin);
freopen("shooting.out","w",stdout);
scanf("%d%d",&n,&m);
for(int i=1;i<=n;i++)scanf("%d%d%d",&b[i].l1,&b[i].r1,&b[i].s);
root[0]=maketree(1,200000);
for(int i=1;i<=m;i++){
scanf("%d",&a1);
root[i]=treein(root[i-1],1,200000);
}
for(int i=1;i<=n;i++){
a1=1;a2=m;int an=0;
while(a1<=a2){
int mid=(a1+a2)>>1;
if(treeout(root[mid],1,200000,b[i].l1,b[i].r1)<b[i].s)a1=mid+1;
else a2=mid-1,an=mid;
}
if(an)ans[an]++;
}
for(int i=1;i<=m;i++)printf("%d\n",ans[i]);
fclose(stdin);fclose(stdout);
return 0;
}
int u=hs();
int main(){;}