代码如下:
#include <iostream>
using namespace std;
struct youhui{
long long time,price;
bool have;
}a[1000];
long long alen=-1;
bool afind(long long p,long long q) //p是价格,q是时间
{
for(int i=0;i<=alen;i++)
{
if(a[i].have)
if(q-a[i].time<=45)
if(p<=a[i].price)
{a[i].have=false;
return true;}
}
return false;
}
int main()
{
long long money=0;
// freopen("transfer.in","r",stdin);
// freopen("transfer.out","w",stdout);
int n;
cin>>n;
int d,b,c;
for(int i=0;i<n;i++)
{
cin>>d>>b>>c;
if(d==0)
{
money+=b;
alen++;
a[alen].price=b;
a[alen].time=c;
a[alen].have=true;
}else
if(!afind(b,c))money+=b;
}
cout<<money;
// fclose(stdin);
// fclose(stdout);
return 0;
}