From 4ad06dfc25bbc0e0a2d202becbfa8266727f6ee4 Mon Sep 17 00:00:00 2001 From: hanyixuanten <105723997+hanyixuanten@users.noreply.github.com> Date: Wed, 15 Jul 2026 16:35:41 +0800 Subject: [PATCH] new file: P5661.cpp --- P5661.cpp | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 P5661.cpp diff --git a/P5661.cpp b/P5661.cpp new file mode 100644 index 0000000..7e75fdb --- /dev/null +++ b/P5661.cpp @@ -0,0 +1,43 @@ +#include +using namespace std; +struct T +{ + int price, time; + bool used; +} q[100005]; +int head, tail, n, cost; +int main() +{ +// freopen("transfer.in","r",stdin); +// freopen("transfer.out","w",stdout); + 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) + { + found = 1, q[j].used = 1; + break; + } + } + if (!found) + cost += price; + } + } + cout << cost << endl; + return 0; +} \ No newline at end of file