Language: C++

#include <bits/stdc++.h>
using namespace std;

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 1
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define TO_STRING(VariableName) # VariableName
#define LOG(x) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<endl;
#define LOG2(x,y) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<endl;
#define LOG3(x,y,z) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;
#define LOG4(w,x,y,z) if(DEBUG)cout<<TO_STRING(w)<<"="<<w<<" "<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;

template<class T>bool chmax(T & a, const T & b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }

void solve(){

    lli ans = 0;
    priority_queue<pair<lli,lli>> q;
    priority_queue<pair<lli,lli>,vector<pair<lli,lli>>,greater<pair<lli,lli>>> qq;

    lli n;
    cin>>n;
    REP(i,0,n){
        lli k,l,r;
        cin>>k>>l>>r;
        if(l-r>0){
            q.push({k,l-r});
            ans += r;
        }
        else{
            qq.push({k,r-l});
            ans += l;
        }
    }

    lli now = 0;

    multiset<lli> s;
    lli cnt = 0;
    for(lli i=n;i>=1;i--){
        while(q.size() && q.top().first >= i){
            s.insert(q.top().second);
            q.pop();
        }
        if(s.size()==0)continue;
        ans += (*s.rbegin());
        s.erase(s.rbegin());
    }

    s.clear();
    for(lli i=cnt+1;i<=n;i++){
        while(qq.size() && qq.top().first < i){
            s.insert(qq.top().second);
            qq.pop();
        }
        if(s.size()==0)continue;
        ans += (*s.rbegin());
        s.erase(s.rbegin());
    }
    cout<<ans<<endl;

}


int main(){

    lli t;
    cin>>t;
    while(t--)solve();

    return 0;
}


Compiler output:
a.cc: In function 'void solve()':
a.cc:53:16: error: no matching function for call to 'std::multiset<long long int>::erase(std::multiset<long long int>::reverse_iterator)'
   53 |         s.erase(s.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
a.cc:64:16: error: no matching function for call to 'std::multiset<long long int>::erase(std::multiset<long long int>::reverse_iterator)'
   64 |         s.erase(s.rbegin());
      |         ~~~~~~~^~~~~~~~~~~~
/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