30分RE玄关求助
查看原帖
30分RE玄关求助
1195678
wky2011楼主2024/8/18 12:35
#include<bits/stdc++.h>
#define ll long long
#define int long long
#define re read()
using namespace std;
const int N=3e5+5;
const int NN=3e3+5;
inline ll read(){
    ll 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;
}
struct yhjjgt{
	int jg,zs;
}yhj[1000005];
signed main(){
ios::sync_with_stdio(false);
int n=re,jq=0,j=0,s=1;
for(int i=1;i<=n;i++) {
	int aa=re,jqq=re,sj=re;
	if(aa==0){
		j++;
		yhj[j].jg=jqq;
		yhj[j].zs=sj+45;
		jq+=jqq;
		//cout<<"dt"<<sj<<' '<<jqq<<'\n';
	}
	else{
		if(sj>yhj[s].zs)
		while(sj>yhj[s].zs&&s<j) s++;
		int k=0;
		bool bo=0;
		if(jqq<=yhj[s].jg&&sj<=yhj[s].zs){
			s++;
			//cout<<"gj"<<sj<<' '<<0<<"else"<<'\n';
		}
		
		else if(sj>yhj[s].zs){
			jq+=jqq;
			//cout<<"gj"<<sj<<' '<<jqq<<'\n';s++;
			//cout<<"gj"<<sj<<' '<<0<<"else"<<'\n';
		}
		else{
		while(jqq>yhj[s+k].jg&&s<j){
		k++;
		if(jqq<=yhj[s+k].jg){
			s++;
			bo=1;
			//cout<<"gj"<<sj<<' '<<0<<"while"<<'\n';
			break;
		}
		}
		if(bo==0){
		
			jq+=jqq;
			//cout<<"gj"<<sj<<' '<<jqq<<'\n';
		} 
	}}
		
		
	
}
cout<<jq;

return 0;
}

2024/8/18 12:35
加载中...