全WA了,各位dalao们帮忙康康呗~
#include<bits/stdc++.h>
#define N 100005
using namespace std;
int n,L=1,R=0;
pair<int,int>q[N];
bool vis[N];
int main()
{
int type,price,ti;
cin>>n;
int ans=0;
for(int i=1;i<=n;i++)
{
cin>>type>>price>>ti;
if(type==0)
{
q[++R]=make_pair(ti,price);
ans+=price;
}
else
{
while(L<=R&&ti-q[L].first>45)L++;
bool ok=0;
for(int j=L;j<=R;j++)
{
if(!vis[i]&&q[j].second>=price)
{
vis[j]=1;ok=1;
break;
}
}
if(!ok)ans+=price;
}
}
cout<<ans;
return 0;
}