样例全过但全wa求助
查看原帖
样例全过但全wa求助
1048589
HuangBarry楼主2024/10/24 15:12
#include<bits/stdc++.h>
using namespace std;
int n,ans=0,price,t;
bool f;
queue<pair<int,int>>q;
int main(){
	cin>>n;
	while(n--){
		cin>>f>>price>>t;
		if(f){
			while(t>q.front().first&&!q.empty())
				q.pop();
			pair<int,int>v=q.front();
			bool flag=1;
			do{
				if(flag&&price<=q.front().second&&t<=q.front().first){
					flag=0;
					if(q.front()==v)
						break;
				}else
					q.push(q.front());
				q.pop();
			}while(q.front()!=v&&!q.empty());
			if(flag)
				ans+=price;
		}else{
			ans+=price;
			q.push(make_pair(t+45,price));
		}
	}
	cout<<ans<<endl;
	return 0;
} 
2024/10/24 15:12
加载中...