最近脑子不好使,不知道是哪里写错了,求dalao指点......
#include <iostream>
#include <cstdio>
using namespace std;
typedef long long ll;
struct bus {
int way, price, t;
};
struct node {
int T, pri;
bool used;
};
bus a[100000 + 50]; node dc[100000 + 50];
int n, now;
ll ans;
int front, endly;
int main() {
scanf("%d", &n);
for (int i = 1; i <= n; i++)
scanf("%d%d%d", &a[i].way, &a[i].price, &a[i].t);
now = 1;
// int i;
for (int i = 1; i <= n; i++) {
if (!a[i].way) {
dc[++endly].T = a[i].t;
dc[endly].pri = a[i].price;
dc[endly].used = false;
ans += a[i].price;
continue;
}
while (a[i].t - dc[front].T > 45 && front <= endly) ++front;
// puts("ok");
bool found = false;
for (int j = front; j <= endly; j++)
if (dc[j].pri >= a[i].price && !dc[j].used) {
dc[j].used = false;
found = true;
break;
}
if (!found) ans += a[i].price;
}
printf("%d\n", ans);
return 0;
}