#include using namespace std;  class SpecialAverage {public:                multiset left, mid, right;      int n, k;                      long pos, sum;          vector v;                  SpecialAverage(int nvalue, int kvalue)    {        n = nvalue;        k = kvalue;        pos = 0;        sum = 0;        for (int i = 0; i < n; i++)            v.push_back(0);    }                  void add(int num)    {                        left.insert(num);                          if (left.size() > k) {                                                  int temp = *(prev(end(left)));                                      mid.insert(temp);                                      left.erase(prev(end(left)));                                      sum += temp;        }                          if (mid.size() > (n – 2 * k)) {                                                  int temp = *(prev(end(mid)));                                      right.insert(temp);                                      mid.erase(prev(end(mid)));                                      sum […]

Continue Reading