#include <bits/stdc++.h>
#define USED(VAL) VAL++, VAL--
#define Max (MaxNum - 7)
#define INF 0x3f3f3f3f
#define FastIO ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define max(a, b) (a < b ? b : a)
#define min(a, b) (a < b ? a : b)
#define Endl cout << "\n"
#define endl '\n'
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef double DB;
typedef long double LD;
const int MaxNum = 1e5 + 7;
/*The function of the code was {the functions and ideas...}*/
/*Functions...*/
vector<pair<int, int>> price;
int ans;
int n;
inline void solve(void)
{
cin >> n;
for (int i = 1; i <= n; i++)
{
bool a;
int b;
int t;
cin >> a >> b >> t;
if (!a)
price.push_back({b, t}), ans += b;
else
{
if (price.empty())
{
ans += b;
}
else
{
int id = -1;
for (int i = 0; i < price.size(); i++)
{
if (price[i].second - t > 45)
price.erase(price.begin() + i), i--;
else if (price[i].first < b)
continue;
else if (id == -1)
id = i;
else if (price[i].first > price[id].first || (price[i].first == price[id].first && price[i].second < price[id].second))
id = i;
}
if (id == -1)
ans += b;
else
{
price.erase(price.begin() + id);
}
}
}
cout << ans << '\n';
}
cout << ans;
return;
}
int main()
{
// freopen(".in","r",stdin);
// freopen(".out","w",stdout);
FastIO;
int T;
T = 1;
while (T--)
solve();
return 0;
}
前面的宏定义很多可以不看,马蜂较丑,望dalao谅解