Information
- ID
- 6813
- Time
- 1000ms
- Memory
- 256MiB
- Difficulty
- 7
- Tags
- # Submissions
- 43
- Accepted
- 9
- Uploaded By
#include <bits/stdc++.h>
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 = 0;
for (int j = head; j < tail; j++) {
if (q[j].price >= price && q[j].used == 0) {
found = 1;
q[j].used = 1;
break;
}
}
if (found==0){
cost += price;
}
}
}
cout<<cost<<"\n";
return 0;
}
By signing up a 追梦算法网 universal account, you can submit code and join discussions in all online judging services provided by us.