#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define MAXN 100000
struct node
{
int money, ti, flag = 1; //flag = 1可用
} yhj[MAXN];
int n, ans, type[MAXN], price[MAXN], t[MAXN], yhjnum;
int main()
{
ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
cin >> n;
for (int i = 0 ; i < n ; i++) cin >> type[i] >> price[i] >> t[i];
for (int i = 0 ; i < n ; i++)
{
if (type[i] == 0)
{
yhj[yhjnum].money = price[i];
yhj[yhjnum].ti = t[i];
yhj[yhjnum].flag = 1;
yhjnum++;
ans += price[i];
//cout << "乘坐地铁, ans = " << ans << ", yhjnum = " << yhjnum << "\n";
}
else if (type[i] == 1)
{
int temp = 0; //0 = 没用过优惠
for (int j = 0 ; j < yhjnum ; j++)
{
if (yhj[j].money >= price[i] && t[i] - yhj[j].ti <= 45 && yhj[j].flag == 1)
{
//cout << "需要" << yhj[j].money << "元, 现有" << price[i] << "元, 使用第" << j + 1 << "个优惠卷\n";
yhj[j].flag = 0;
temp = 1;
break;
}
}
if (temp == 0)
{
ans += price[i];
}
//cout << "乘坐公交车, ans = " << ans << ", yhjnum = " << yhjnum << "\n";
}
}
cout << ans;
return 0;
}
求佬调,有回必关