为何不过?
查看原帖
为何不过?
1129279
liangcha_crush_ly楼主2024/7/13 17:20
#include<iostream>
#include<queue>
using namespace std;
int n;
struct ly{
	long long y,p,t;
}a,h[100100];
queue<ly>q;
signed main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		scanf("%lld%lld%lld",&a.y,&a.p,&a.t);
		q.push(a);
	}int s=0,head=1,tail=0;
	while(q.size()){
		ly topp=q.front();
		q.pop();
		if(topp.y==0){
			s+=topp.p;
			h[++tail]=topp;
		}else{
		    if(h[tail].t+45<topp.t)head=tail+1,s+=topp.p;
			else{int flag=0;
			    for(int i=head;i<=tail;i++){
			    	if(h[i].t==0&&h[i].p==0)continue;
			    	if(h[i].t+45>=topp.t&&h[i].p>=topp.p){
			    		h[i].t==0,h[i].p==0;
			    		flag=1;
			    		break;
					}else{
						if(h[i].t+45<topp.t)head=i+1;
					}
				}
				if(flag!=1)s+=topp.p;
			}
		}
	}
	cout<<s;
	return 0;
} 
2024/7/13 17:20
加载中...