0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-12-24 18:11:59 +00:00

P2073 送花

R42137379
This commit is contained in:
Baoshuo Ren 2020-11-18 21:36:43 +08:00 committed by Baoshuo Ren
parent 87b094aca2
commit dc8ef4784b
Signed by: baoshuo
GPG Key ID: 70F90A673FB1AB68

45
problem/P2073/P2073.cpp Normal file
View File

@ -0,0 +1,45 @@
#include <bits/stdc++.h>
using namespace std;
struct node {
long long w, c;
node() {
w = 0;
c = 0;
}
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;
node ans;
set<node> a;
while (cin >> op, op != -1) {
if (op == 1) {
long long w, c;
cin >> w >> c;
a.insert(node(w, c));
}
else if (op == 2 && !a.empty()) {
a.erase(--a.end());
}
else if (op == 3 && !a.empty()) {
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;
}