Language: C++

#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef pair<int,int>P;
typedef pair<int,P>P2;

signed main(){

  int n,q;

  priority_queue<P2,vector<P2>,greater<P2> >ib;

  cin>>n>>q;
  vector<int>Z;
  vector<P2>v;
  r(i,n){
    int s,t,x;
    scanf("%d%d%d",&s,&t,&x);
    s-=x;
    t-=x;
    s=max(0LL,s);
    if(t<0)continue;
    ib.push(P2(s,P(1,x)));
    ib.push(P2(t,P(-1,x)));
  }

  set<int>st;

  for(int i=0;i<q;i++){
    int x;
    cin>>x;
    while(!ib.empty() && ib.top().F<=x){
      P2 p=ib.top();ib.pop();
      if(p.S.F==1)st.insert(p.S.S);
      else st.erase(p.S.S);
    }
    if(st.size())cout<<*st.begin()<<endl;
    else cout<<-1<<endl;
  }


}


Compiler output:
a.cc: In function 'int main()':
a.cc:21:10: error: no matching function for call to 'max(long long int, int&)'
   21 |     s=max(0LL,s);
      |       ~~~^~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:21:10: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   21 |     s=max(0LL,s);
      |       ~~~^~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:21:10: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   21 |     s=max(0LL,s);
      |       ~~~^~~~~~~
a.cc:32:35: error: 'const __gnu_cxx::__alloc_traits<std::allocator<std::pair<int, std::pair<int, int> > >, std::pair<int, std::pair<int, int> > >::value_type' {aka 'const struct std::pair<int, std::pair<int, int> >'} has no member named 'F'
   32 |     while(!ib.empty() && ib.top().F<=x){
      |                                   ^
a.cc:34:12: error: 'P2' {aka 'struct std::pair<int, std::pair<int, int> >'} has no member named 'S'
   34 |       if(p.S.F==1)st.insert(p.S.S);
      |            ^
a.cc:34:31: error: 'P2' {aka 'struct std::pair<int, std::pair<int, int> >'} has no member named 'S'
   34 |       if(p.S.F==1)st.insert(p.S.S);
      |                               ^
a.cc:35:23: error: 'P2' {aka 'struct std::pair<int, std::pair<int, int> >'} has no member named 'S'
   35 |       else st.erase(p.S.S);
      |                       ^