0分求助
查看原帖
0分求助
506225
_Ventus_楼主2021/10/21 20:52
#include<bits/stdc++.h>
using namespace std;
int l,top=1,s,x,a,b,n;
struct subway{
	bool f;
	int t,p;
}tkt[100001];
int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>x>>a>>b;
		if(!x){  
			tkt[++l].p=a,tkt[l].t=b;
			s+=a;
		}
		else{
			for(int j=top;j<=l;j++){
				if(tkt[j].f&&tkt[j].p>=a&&b-tkt[j].t<=45){
					s-=a;
					tkt[j].f=true;
					break;
				}
			}
			s+=a;
		}
		while(b-tkt[top].t>45&&top<l) top++;
	}
	cout<<s;
	return 0;
}
2021/10/21 20:52
加载中...