mirror of
https://git.sb/baoshuo/OI-codes.git
synced 2024-11-27 17:56:28 +00:00
P1486 [NOI2004] 郁闷的出纳员
R70646888
This commit is contained in:
parent
c40a51310b
commit
92af895516
35
Luogu/P1486/P1486.cpp
Normal file
35
Luogu/P1486/P1486.cpp
Normal file
@ -0,0 +1,35 @@
|
||||
#include <algorithm>
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
|
||||
using std::cin;
|
||||
using std::cout;
|
||||
const char endl = '\n';
|
||||
|
||||
int n, min, k, c, cnt;
|
||||
char op;
|
||||
std::vector<int> a;
|
||||
|
||||
int main() {
|
||||
std::ios::sync_with_stdio(false);
|
||||
cin >> n >> min;
|
||||
while (n--) {
|
||||
cin >> op >> k;
|
||||
if (op == 'I') {
|
||||
if (k >= min) {
|
||||
a.insert(std::lower_bound(a.begin(), a.end(), k - c), k - c);
|
||||
}
|
||||
} else if (op == 'A') {
|
||||
c += k;
|
||||
} else if (op == 'S') {
|
||||
c -= k;
|
||||
auto it = std::lower_bound(a.begin(), a.end(), min - c);
|
||||
cnt += it - a.begin();
|
||||
a.erase(a.begin(), std::lower_bound(a.begin(), a.end(), min - c));
|
||||
} else { // op == 'F'
|
||||
cout << (a.size() < k ? -1 : *(a.end() - k) + c) << endl;
|
||||
}
|
||||
}
|
||||
cout << cnt << endl;
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user