You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

36 lines
760 B

#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
int n;
struct Node {
int f;
int p;
int t;
} a[N];
int ans;
int main() {
cin >> n;
for (int i = 1; i <= n; i++) cin >> a[i].f >> a[i].p >> a[i].t;
for (int i = 1; i <= n; i++) {
if (a[i].f == 0)
ans += a[i].p;
else {
bool flag = false;
for (int j = max(1,j-45); j < i; j++) {
if (a[j].f == 0 && a[i].t - a[j].t <= 45 && a[j].p >= a[i].p) {
flag = true;
a[j].f = -1;
break;
}
}
if (!flag) ans += a[i].p;
}
}
printf("%d\n", ans);
return 0;
}