#include <bits/stdc++.h>
using namespace std;
const int N = 100010;
const int INF = (int) 1e9;
struct node {
int flag, price, t;
} a[N];
int b[N], tot;
int main() {
int n;
scanf("%d", &n);
for (int i = 1; i <= n; i++) {
scanf("%d%d%d", &a[i].flag, &a[i].price, &a[i].t);
}
int sum = 0;
for (int i = 1; i <= n; i++) {
if (!a[i].flag) {
sum += a[i].price;
b[++tot] = i;
}
else {
int pos = 0;
for (int j = tot; j >= tot - 45; j--) {
if (a[b[j]].t + 45 >= a[i].t && a[b[j]].price >= a[i].price) pos = j;
}
if (pos) a[b[pos]].t = -INF;
else sum += a[i].price;
}
}
printf("%d\n", sum);
return 0;
}
有没有大佬给解答一下啊QAQ