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;
typedef pair<string,P>PP;
#define F first
#define S second
int dy[]={-1,0,1,0};
int dx[]={0,1,0,-1};

int MEMO[1200009];

signed main(){
  r(i,1200009)MEMO[i]=2147483647;


  int n,q;
  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;
    t--;
    //cout<<s<<' '<<t<<endl;
    s=max(0LL,s);
    if(t<0)continue;
    //cout<<s<<' '<<t<<endl;
    v.push_back(P2(x,P(s,t)));
    Z.push_back(s);
    Z.push_back(t);
    Z.push_back(s+1);
    if(t!=0)Z.push_back(t-1);
    if(s!=0)Z.push_back(s-1);
    Z.push_back(t+1);
  }

  unordered_map<int,int>M_nz;
  unordered_map<int,int>M_zn;
  sort(Z.begin(),Z.end());
  Z.erase(unique(Z.begin(),Z.end()),Z.end());
  int cnt=0;
  r(i,Z.size()){
    //cout<<' '<<Z[i]<<endl;
    M_zn[cnt]=Z[i];
    M_nz[Z[i]]=cnt;
    cnt++;
  }

  vector<P2>SSS;

  r(i,v.size()){
    //cout<<v[i].S.F<<' '<<v[i].S.S<<endl;
    int l=M_nz[v[i].S.F];
    int r=M_nz[v[i].S.S];
    int x=v[i].F;
    //cout<<l<<' '<<r<<' '<<x<<endl;
    SSS.push_back(P2(x,P(l,r+1)));
    //seg.Set(l,r+1,x);
  }

  set<int>st;
  r(i,1200009)st.insert(i);
  sort(SSS.begin(),SSS.end());


  r(i,SSS.size()){
    int l=SSS[i].S.F;
    int r=SSS[i].S.S;r--;
    int x=SSS[i].F;

    auto L=st.lower_bound(l);
    if(*L >r )continue;
    auto R=st.upper_bound(r);
    
    auto T=st.lower_bound(l);
    while(T!=R){
      MEMO[*T]=x;
      T++;
    }
    st.erase(L,R);
  }

 // r(i,10)cout<<" "<<MEMO[i]<<endl;


  r(i,q){
    int x;
    scanf("%d",&x);
    int len=lower_bound(Z.begin(),Z.end(),x)-Z.begin();
    int t=*lower_bound(Z.begin(),Z.end(),x);

    //cout<<len<<endl;

    ///int p=seg.Get(len,len+1);

    if(t==x){
      int p=MEMO[len];

      if(p==2147483647)cout<<-1<<endl;
      else cout<<p<<endl;
    }
    else if(lower_bound(Z.begin(),Z.end(),x)==Z.end()){
      cout<<-1<<endl;
    }
    else{
      int p=MEMO[len-1];

      if(p==2147483647)cout<<-1<<endl;
      else cout<<p<<endl;
      //cout<<seg.Get(len-1,len)<<endl;
    }
    //cout<<endl;
  }


}

Compiler output:
a.cc: In function 'int main()':
a.cc:30:10: error: no matching function for call to 'max(long long int, int&)'
   30 |     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:30:10: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   30 |     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:30:10: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   30 |     s=max(0LL,s);
      |       ~~~^~~~~~~