#include <bits/stdc++.h>
using namespace std;
struct tran
{
int ftime;//jie shu shi jian
int prime;//jia zhi
bool used;//neng bu neng yong
}a[100010];
int headpos;
int tailpos;//wei zuo biao
int main()
{
int n;
cin >>n;
int ans=0;
for(int i = 1;i <= n;i++)
{
int ub,coin,time;
cin >>ub>>coin>>time;
if(!ub)//underground
{
ans+=coin;
a[tailpos].ftime=time+45;
a[tailpos].prime=coin;
a[tailpos].used=0;
tailpos++;
}
else
{
while(headpos<=tailpos&&a[headpos].ftime<=time)
{
headpos++;
}
bool ist=0;
for(int j = headpos;j <= tailpos;j++)
{
if(a[j].prime>=coin&&a[j].used==0)
{
a[j].used=1;
ist=1;
}
}
if(!ist)
{
ans+=coin;
}
}
}
cout <<ans;
return 0;
}
万能的神犇,帮我看看