0分求调
查看原帖
0分求调
955228
OIer_xhy楼主2025/7/26 22:13
#include<bits/stdc++.h>
using namespace std;
struct node{
	int price,time;
}tmp;
int n;
bool trans;
int ans=0;
queue<node>tickets;
int use_tickets(int p,int t){
	bool flag=0;
	int sz=tickets.size();
	for(int i=1;i<=sz;i++){
		if(t-tickets.front().time>45){
			tickets.pop();
			continue;
		}
		if(p<=tickets.front().price) flag=1;
		tickets.push(tickets.front());
		tickets.pop();
	}
	if(flag) return 0;
	return p;
}
int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>trans>>tmp.price>>tmp.time;
		if(trans==0){
			ans+=tmp.price;
			tickets.push({tmp.price,tmp.time});
		}
		else{
			tmp.price=use_tickets(tmp.price,tmp.time);
			ans+=tmp.price; 
		}
	}
	cout<<ans;
	return 0;
}

2025/7/26 22:13
加载中...