Write a program to compute the most common statistical measures (minimum, maximum and average) of several integer numbers.

These numbers are known increasingly. At every moment, it is also possible to delete the smallest element.

Input: A sequence of (possibly, many) numbers, together with deleting instructions, as can be seen in the sample input. The numbers may be repeated. Deleting means removing the smallest element (one instance of it, if it is repeated). If there are no elements, deleting does nothing.

Output: After every instruction of the input, print the minimum, maximum and average of the current elements with four digits after the decimal point, or tell that there are no elements. Follow the format of the sample output.

  • Try to use a priority_queue with first element the smallest among the ones seen so far.

  • To output a double x with 4 digits of precision you can use #include<iomanip> and cout << fixed << setprecision(4) << the double you want to output.

  • #include<limits> allows you to access e.g. the smallest int with numeric_limits<int>::lowest().

//STL - Statistical measures
#include<iostream>
#include<queue>
#include<limits>
#include<iomanip>

using namespace std;

const auto MININFTY = numeric_limits<int>::lowest();

int main(){
    string op;
    priority_queue<int,vector<int>,greater<int>> q;
    int sum = 0;
    int max = MININFTY;
    while (cin >> op){
        if (op == "delete"){ 
            // do something
        }
        else{// case of "number"
            // do something 
        } 
        int sz = q.size();
        if (sz == 0) cout << "no elements" << endl;
        else{
            // do something
            // to output a double x with 4 digits of precision use 
            // cout << fixed << setprecision(4) << x
        }
    }
}
//STL - Satistical measures
#include<iostream>
#include<queue>
#include<limits>
#include<iomanip>

using namespace std;

const auto MININFTY = numeric_limits<int>::lowest();

int main(){
    string op;
    priority_queue<int,vector<int>,greater<int>> q;
    int sum = 0;
    int max = MININFTY;
    while (cin >> op){
        if (op == "delete"){ 
            if (not q.empty()){
                sum -=q.top();
                q.pop();
                if (q.empty()) max = MININFTY;
            }
        }
        else{// case of "number"
            int value;
            cin >> value;
            q.push(value);
            sum +=value;
            if (value > max) max = value; 
        } 
        int sz = q.size();
        if (sz == 0) cout << "no elements" << endl;
        else{
            double avg = double(sum) / sz;
            cout << "minimum: " << q.top();
            cout << ", maximum: " << max;
            cout << ", average: " << fixed << setprecision(4) << avg << endl;
        }
    }
}