30wa悬关
查看原帖
30wa悬关
973971
xfx2011楼主2024/3/22 20:04
#include<bits/stdc++.h>
using namespace std;
int n;
struct node{
	long long price,t;
	node(long long _price,long long _t){
		price = _price;
		t = _t;
	}
};
queue<node>q;
queue<node>q1;
typedef long long ll;
ll ans = 0;
int main(){
	freopen("p5661_1.in","r",stdin);
	freopen("p5661.out","w",stdout);
	cin >> n;
	for(int i = 1;i <= n;i ++){
		int op;
		cin >> op;
		int price,t;
		cin >> price >> t;
		if(op == 0){
			q.push(node(price,t + 45)); // 到期时间
			ans += price;
			continue;
		}
		while(!q.empty() && t > q.front().t)
			q.pop();
		while(!q.empty() && q.front().price < price){
			node u = q.front();
			q1.push(u);
			q.pop();
		}
		if(!q.empty()){
			q.pop();
			while(!q1.empty()){
				q.push(q1.front());
				q1.pop();
			}
		}else	
			ans += price;
	}
	cout << ans;
	return 0;
}
2024/3/22 20:04
加载中...