CODE:
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
struct init
{
int p, t;
bool flag;
} q[N];
int ans, t, j, n;
int main()
{
cin >> n;
int type, money, start;
for (int i = 1; i <= n; i++)
{
cin >> type >> money >> start;
if (type == 0)
{ // 地铁
ans += money;
t++;
q[t].p = money;
q[t].t = start + 45;
q[t].flag = false;
}
else
{ // 公交
for (j = 1; j <= t; j++)
{
if (q[j].p >= money && q[j].t >= start && q[j].flag == false)
{
q[j].flag = true;
break;
}
}
if (j > t)
{
ans += money;
}
}
}
cout << ans;
return 0;
}