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

#629. 0818剑与魔法(dragons)

https://sjzezoj.com/submission/18931
This commit is contained in:
Baoshuo Ren 2021-08-19 08:34:14 +08:00 committed by Baoshuo Ren
parent b3cce7edee
commit 0ae24246f8
Signed by: baoshuo
GPG Key ID: 70F90A673FB1AB68

28
S2OJ/629/629.cpp Normal file
View File

@ -0,0 +1,28 @@
#pragma GCC optimize(2)
#include <bits/stdc++.h>
using namespace std;
int n, x, ans;
char op;
priority_queue<int, vector<int>, greater<int>> q;
int main() {
std::ios::sync_with_stdio(false);
cin >> n;
for (int i = 1; i <= n; i++) {
cin >> op >> x;
if (op == 'c') {
q.push(x);
} else {
while (q.size() >= x && i != n) q.pop();
}
}
while (!q.empty()) {
ans += q.top();
q.pop();
}
cout << ans << endl;
return 0;
}