Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- #include <iomanip>
- using namespace std;
- typedef long long ll;
- const ll X = 1000000 + 10000;
- ll fenvals[X + 1];
- void update(ll i, ll change) {
- while (i <= X) {
- fenvals[i] += change;
- i |= i + 1;
- }
- }
- ll psum(ll i) {
- int sum = 0;
- while (i >= 0) {
- sum += fenvals[i];
- i &= i + 1;
- i--;
- }
- return sum;
- }
- int main() {
- ios::sync_with_stdio(false), cin.tie(0);
- double count = 0;
- while (true) {
- string oper;
- cin >> oper;
- if (oper == "QUIT") {
- break;
- }
- double raw_x;
- cin >> raw_x;
- ll x = floor(100*raw_x + 0.5);
- if (oper == "BID") {
- update(x, 1);
- } else if (oper == "DEL") {
- update(x, -1);
- } else {
- ll k;
- cin >> k;
- count += min(k, psum(X) - psum(x - 1));
- }
- }
- count /= 100;
- cout << fixed << setprecision(2) << count;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement