#include <iostream>

using namespace std;
const int MAXN = 100005;
struct Ticket {
    int price, time, used;
} q[MAXN];
int head, tail, n, cost;

int main() {
    cin >> n;
    for (int i = 0; i < n; ++i) {
        int op, price, time;
        cin >> op >> price >> time;
        if (op == 0) {
            cost += price;
            q[tail].time = time + 45;
            q[tail++].price = price;
        } else {
            while (head < tail && q[head].time < time) {
                head++;
            }
            bool found = false;
            for (int j = head; j < tail; ++j) {
                if (q[j].price >= price && q[j].used == 0) {
                    found = true;
                    q[j].used = 1;
                    break;
                }
            }
            if (!found) cost += price;
        }
    }
    cout << cost << endl;
    return 0;
}

1 条评论

  • 1

信息

ID
417
时间
1000ms
内存
256MiB
难度
8
标签
递交数
24
已通过
6
上传者