RT,代码如下
#include <iostream>
#define q_empty (tail-head>=0)
using namespace std;
const int MAXN=1e5+5;
struct tkt
{
int time,price;
bool used;
}q[MAXN];
int head=1,tail=0,n,tp,pr,tm,ans;
int main()
{
cin >> n;
for(int i = 1;i <= n;i ++)
{
cin >> tp >> pr >> tm;
if(tp==0)
{
ans+=pr;
q[++tail] = tkt{tm,pr,false};
}else
{
bool fd=false;
while(head<=tail && tm-q[head].time>45 || q[head].used)
head++;
if(!q_empty)
{
for(int j = head;j <= tail;j ++)
if(q[j].price>=pr && (!q[j].used))
{fd=true;q[j].used=true;
break;}
if(!fd) ans+=pr;
}
else ans+=pr;
}
}
cout << ans << endl;
return 0;
}