0pts求调玄关
查看原帖
0pts求调玄关
1359427
ingo_dtw楼主2024/10/12 22:25

rt

#include<bits/stdc++.h>
using namespace std;
struct cz
{
	int jq,sj,s=0;
};
queue <cz> q;
template <class T>T read()
{
	T f=1,r=0;char c=getchar();
	while((c<'0'||c>'9')&&c!='-') c=getchar();
	if(c=='-') f=-1,c=getchar();
	while(c>='0'&&c<='9') r=r*10+c-'0',c=getchar();
	return f*r; 
}
int main()
{
	int n=read<int>(),sum=0;
	for(int i=1;i<=n;i++)
	{
		cz h; 
		int op,x,y;
		cin>>op>>x>>y;
		if(op==0)
		{
			sum+=x;
			h.jq=x;
			h.sj=y;
			h.s=1;
			q.push(h);
		}
		else
		{
			h=q.front();
			if(h.s==0)
			{
				bool f=1; 
				while(!q.empty())
				{
					cz n=q.front();
					if(n.s==1&&abs(n.sj-y)<=45)
					{
						f=0;
						q.pop();
						break;
					}
					q.pop();
				}
				if(f) 
				{
					sum+=x;
					continue;
				}
			}
			else if(abs(h.sj-y)<=45&&!q.empty())
			{
				q.pop();
			}
			else
			{
				sum+=x;
			}
		}
	}
	cout<<sum;
	return 0;
}

2024/10/12 22:25
加载中...