84pts求调
查看原帖
84pts求调
1063615
Scez楼主2024/8/7 15:06
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
using namespace std;
inline int read()
{
	int x=0,f=1;char ch=getchar();
	while (ch<'0'||ch>'9'){if (ch=='-') f=-1;ch=getchar();}
	while (ch>='0'&&ch<='9'){x=x*10+ch-48;ch=getchar();}
	return x*f;
}
int c,s,R;
int t[414514];
int l,r,x;
int tag[114514];
int ls(int p){return p<<1;}
int rs(int p){return p<<1|1;} 
void push_down(int p)
{
	if(tag[p])
	{
		t[ls(p)]+=tag[p];
		t[rs(p)]+=tag[p];
		tag[ls(p)]+=tag[p];
		tag[rs(p)]+=tag[p];
		tag[p]=0;
	}
}
void update(int p,int l,int r,int L,int R,int d)
{
	if(L<=l&&r<=R)
	{
		t[p]+=d;
		tag[p]+=d;
		return;
	}
	push_down(p);
	int mid=(l+r)>>1;
	if(L<=mid)
	update(ls(p),l,mid,L,R,d);
	if(R>mid)
	update(rs(p),mid+1,r,L,R,d);
	t[p]=max(t[ls(p)],t[rs(p)]);
}
int query(int p,int l,int r,int L,int R)
{
	if(L<=l&&r<=R)
	return t[p];
	push_down(p);
	int mid=(l+r)>>1;
	int ans=-1;
	if(L<=mid)
	ans=max(ans,query(ls(p),l,mid,L,R));
	if(R>mid)
	ans=max(ans,query(rs(p),mid+1,r,L,R));
	return ans;
}
int main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	cin>>c>>s>>R;
	while(R--)
	{
		cin>>l>>r>>x;
		if(query(1,1,c,l,r-1)+x<=s)
		{
			update(1,1,c,l,r-1,x);
			cout<<'T'<<endl;
		}
		else
		cout<<'N'<<endl;
	}
	return 0;
}

2024/8/7 15:06
加载中...