0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-12-18 10:52:00 +00:00
OI-codes/Luogu/P2073/P2073.cpp

45 lines
843 B
C++
Raw Normal View History

2020-11-18 13:36:43 +00:00
#include <bits/stdc++.h>
using namespace std;
struct node {
long long w, c;
node() {
w = 0;
c = 0;
}
2022-05-20 01:23:27 +00:00
2020-11-18 13:36:43 +00:00
node(long long _w, long long _c) {
w = _w;
c = _c;
}
bool operator<(const node a) const {
return c < a.c;
}
};
int main() {
long long op;
2021-11-19 09:01:13 +00:00
node ans;
2020-11-18 13:36:43 +00:00
set<node> a;
while (cin >> op, op != -1) {
if (op == 1) {
long long w, c;
cin >> w >> c;
a.insert(node(w, c));
2021-11-19 09:01:13 +00:00
} else if (op == 2 && !a.empty()) {
2020-11-18 13:36:43 +00:00
a.erase(--a.end());
2021-11-19 09:01:13 +00:00
} else if (op == 3 && !a.empty()) {
2020-11-18 13:36:43 +00:00
a.erase(a.begin());
}
}
for (set<node>::iterator it = a.begin(); it != a.end(); it++) {
ans.c += it->c;
ans.w += it->w;
}
cout << ans.w << ' ' << ans.c << endl;
return 0;
}