比赛 NOIP模拟赛1 评测结果 TTTTTTTTTTTTTTTTTTTT
题目名称 天天爱射击 最终得分 0
用户昵称 niiick 运行时间 20.000 s
代码语言 C++ 内存使用 11.17 MiB
提交时间 2018-02-08 20:42:17
显示代码纯文本
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<queue>
#include<cstring>
using namespace std;

int read()
{
    int f=1,x=0;
    char ss=getchar();
    while(ss<'0'||ss>'9'){if(ss=='-')f=-1;ss=getchar();}
    while(ss>='0'&&ss<='9'){x=x*10+ss-'0';ss=getchar();}
    return x*f;
}

void print(int x)
{
    if(x<0){putchar('-');x=-x;}
    if(x>9)print(x/10);
    putchar(x%10+'0');
}

int n,m;
struct node{int x,y,s;}E[1000010];
bool cmp(node a,node b){if(a.x==b.x)return a.y<b.y;return a.x<b.x;}

int main()
{
	freopen("shooting.in","r",stdin);
	freopen("shooting.out","w",stdout);
	n=read();m=read();
	for(int i=1;i<=n;i++)
	E[i].x=read(),E[i].y=read(),E[i].s=read();
	
	sort(E+1,E+1+m,cmp);
	
	for(int i=1;i<=m;i++)
	{
		int x=read();
		int mid=(1+n)>>1;
		int ans=0;
		while(1)
		{
			if(E[mid].x<=x&&E[mid+1].x>=x)break;
			if(E[mid].x>=x)mid=(1+mid)>>1;
			if(E[mid].x<=x)mid=(mid+n)>>1;
		}
		for(int j=1;j<=mid;j++)
		{
			if(E[j].y>x) E[j].s--;
			if(E[j].s==0) ans++;
		}
		print(ans);printf("\n");
	}
	fclose(stdin);
	fclose(stdout);
	return 0;
}