Language: C++

#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
// const ll MOD = 1000000007;

int main() {
  int Q;
  cin>>Q;
  multiset<ll> st1,st2;
  st1.insert(-(1e9 + 1));
  st2.insert(1e9 + 1);
  ll res = 0;
  for (int i = 0; i < Q; i++) {
    int c; cin>>c;
    if (c == 1) {
      ll a,b;
      cin>>a>>b;
      res += b;
      ll left = *st1.rbegin();
      ll right = *st2.begin();
      if (left <= a && a <= right) {
        st1.insert(a);
        st2.insert(a);
      } else if (a < left) {
        st1.insert(a);
        st1.insert(a);
        st1.erase(st1.rbegin());
        st2.insert(left);
        res += left - a;
      } else {
        st2.insert(a);
        st2.insert(a);
        st2.erase(st2.begin());
        st1.insert(right);
        res += a - right;
      }
    } else {
      ll kyoku = *st1.rbegin();
      cout<<kyoku<<" "<<res<<endl;
    }
  }
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:29:18: error: no matching function for call to 'std::multiset<long long int>::erase(std::multiset<long long int>::reverse_iterator)'
   29 |         st1.erase(st1.rbegin());
      |         ~~~~~~~~~^~~~~~~~~~~~~~
In file included from /usr/include/c++/14/set:64,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:158,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_multiset.h:641:7: note: candidate: 'std::multiset<_Key, _Compare, _Alloc>::iterator std::multiset<_Key, _Compare, _Alloc>::erase(const_iterator) [with _Key = long long int; _Compare = std::less<long long int>; _Alloc = std::allocator<long long int>; iterator = std::_Rb_tree<long long int, long long int, std::_Identity<long long int>, std::less<long long int>, std::allocator<long long int> >::const_iterator; const_iterator = std::_Rb_tree<long long int, long long int, std::_Identity<long long int>, std::less<long long int>, std::allocator<long long int> >::const_iterator]'
  641 |       erase(const_iterator __position)
      |       ^~~~~
/usr/include/c++/14/bits/stl_multiset.h:641:28: note:   no known conversion for argument 1 from 'std::multiset<long long int>::reverse_iterator' {aka 'std::reverse_iterator<std::_Rb_tree_const_iterator<long long int> >'} to 'std::multiset<long long int>::const_iterator' {aka 'std::_Rb_tree<long long int, long long int, std::_Identity<long long int>, std::less<long long int>, std::allocator<long long int> >::const_iterator'}
  641 |       erase(const_iterator __position)
      |             ~~~~~~~~~~~~~~~^~~~~~~~~~
/usr/include/c++/14/bits/stl_multiset.h:671:7: note: candidate: 'std::multiset<_Key, _Compare, _Alloc>::size_type std::multiset<_Key, _Compare, _Alloc>::erase(const key_type&) [with _Key = long long int; _Compare = std::less<long long int>; _Alloc = std::allocator<long long int>; size_type = long unsigned int; key_type = long long int]'
  671 |       erase(const key_type& __x)
      |       ^~~~~
/usr/include/c++/14/bits/stl_multiset.h:671:29: note:   no known conversion for argument 1 from 'std::multiset<long long int>::reverse_iterator' {aka 'std::reverse_iterator<std::_Rb_tree_const_iterator<long long int> >'} to 'const std::multiset<long long int>::key_type&' {aka 'const long long int&'}
  671 |       erase(const key_type& __x)
      |             ~~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_multiset.h:693:7: note: candidate: 'std::multiset<_Key, _Compare, _Alloc>::iterator std::multiset<_Key, _Compare, _Alloc>::erase(const_iterator, const_iterator) [with _Key = long long int; _Compare = std::less<long long int>; _Alloc = std::allocator<long long int>; iterator = std::_Rb_tree<long long int, long long int, std::_Identity<long long int>, std::less<long long int>, std::allocator<long long int> >::const_iterator; const_iterator = std::_Rb_tree<long long int, long long int, std::_Identity<long long int>, std::less<long long int>, std::allocator<long long int> >::const_iterator]'
  693 |       erase(const_iterator __first, const_iterator __last)
      |       ^~~~~
/usr/include/c++/14/bits/stl_multiset.h:693:7: note:   candidate expects 2 arguments, 1 provided