Language: C++

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
using vi=vector<ll>;
using vvi=vector<vector<ll>>;
using vc=vector<char>;
using vvc=vector<vector<char>>;
const int inf=1000000007;
const int mod=1000000007;
void chmin(auto &a,auto b){if(b<a)a=b;}
void chmax(auto &a,auto b){if(a<b)a=b;}
int main(){
  int n,q;cin>>n>>q;
  vector<PP> p(n);
  rep(i,n){
    int s,t,x;cin>>s>>t>>x;
    get<0>(p[i])=x-t+1;
    get<1>(p[i])=x-s;
    get<2>(p[i])=x;
  }
  set<P> s;
  vi ans(q);
  rep(i,q){
    int a;cin>>a;
    s.insert(P(a,i));
  }
  rep(i,n){
    if(p.size()==0)break;
    int a=get<0>(p[i]),b=get<1>(p[i]);
    int from=lower_bound(s.begin(),s.end(),P(a,-1));
    int to=upper_bound(s.begin(),s.end(),P(b,-1));
    rep(j,to-from){
      ans[s[from].second]=get<2>(p[i]);
      s.erase(from);
    }
  }
  rep(i,q)cout<<ans[i]<<endl;
}

Compiler output:
a.cc:13:12: warning: use of 'auto' in parameter declaration only available with '-std=c++20' or '-fconcepts'
   13 | void chmin(auto &a,auto b){if(b<a)a=b;}
      |            ^~~~
a.cc:13:20: warning: use of 'auto' in parameter declaration only available with '-std=c++20' or '-fconcepts'
   13 | void chmin(auto &a,auto b){if(b<a)a=b;}
      |                    ^~~~
a.cc:14:12: warning: use of 'auto' in parameter declaration only available with '-std=c++20' or '-fconcepts'
   14 | void chmax(auto &a,auto b){if(a<b)a=b;}
      |            ^~~~
a.cc:14:20: warning: use of 'auto' in parameter declaration only available with '-std=c++20' or '-fconcepts'
   14 | void chmax(auto &a,auto b){if(a<b)a=b;}
      |                    ^~~~
a.cc: In function 'int main()':
a.cc:33:25: error: cannot convert 'std::_Rb_tree_const_iterator<std::pair<long long int, long long int> >' to 'int' in initialization
   33 |     int from=lower_bound(s.begin(),s.end(),P(a,-1));
      |              ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
      |                         |
      |                         std::_Rb_tree_const_iterator<std::pair<long long int, long long int> >
a.cc:34:23: error: cannot convert 'std::_Rb_tree_const_iterator<std::pair<long long int, long long int> >' to 'int' in initialization
   34 |     int to=upper_bound(s.begin(),s.end(),P(b,-1));
      |            ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
      |                       |
      |                       std::_Rb_tree_const_iterator<std::pair<long long int, long long int> >
a.cc:36:12: error: no match for 'operator[]' (operand types are 'std::set<std::pair<long long int, long long int> >' and 'int')
   36 |       ans[s[from].second]=get<2>(p[i]);
      |            ^
a.cc:37:14: error: no matching function for call to 'std::set<std::pair<long long int, long long int> >::erase(int&)'
   37 |       s.erase(from);
      |       ~~~~~~~^~~~~~
In file included from /usr/include/c++/14/set:63,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:158,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_set.h:656:7: note: candidate: 'std::set<_Key, _Compare, _Alloc>::iterator std::set<_Key, _Compare, _Alloc>::erase(const_iterator) [with _Key = std::pair<long long int, long long int>; _Compare = std::less<std::pair<long long int, long long int> >; _Alloc = std::allocator<std::pair<long long int, long long int> >; iterator = std::_Rb_tree<std::pair<long long int, long long int>, std::pair<long long int, long long int>, std::_Identity<std::pair<long long int, long long int> >, std::less<std::pair<long long int, long long int> >, std::allocator<std::pair<long long int, long long int> > >::const_iterator; const_iterator = std::_Rb_tree<std::pair<long long int, long long int>, std::pair<long long int, long long int>, std::_Identity<std::pair<long long int, long long int> >, std::less<std::pair<long long int, long long int> >, std::allocator<std::pair<long long int, long long int> > >::const_iterator]'
  656 |       erase(const_iterator __position)
      |       ^~~~~
/usr/include/c++/14/bits/stl_set.h:656:28: note:   no known conversion for argument 1 from 'int' to 'std::set<std::pair<long long int, long long int> >::const_iterator' {aka 'std::_Rb_tree<std::pair<long long int, long long int>, std::pair<long long int, long long int>, std::_Identity<std::pair<long long int, long long int> >, std::less<std::pair<long long int, long long int> >, std::allocator<std::pair<long long int, long long int> > >::const_iterator'}
  656 |       erase(const_iterator __position)
      |             ~~~~~~~~~~~~~~~^~~~~~~~~~
/usr/include/c++/14/bits/stl_set.h:686:7: note: candidate: 'std::set<_Key, _Compare, _Alloc>::size_type std::set<_Key, _Compare, _Alloc>::erase(const key_type&) [with _Key = std::pair<long long int, long long int>; _Compare = std::less<std::pair<long long int, long long int> >; _Alloc = std::allocator<std::pair<long long int, long long int> >; size_type = long unsigned int; key_type = std::pair<long long int, long long int>]'
  686 |       erase(const key_type& __x)
      |       ^~~~~
/usr/include/c++/14/bits/stl_set.h:686:29: note:   no known conversion for argument 1 from 'int' to 'const std::set<std::pair<long long int, long long int> >::key_type&' {aka 'const std::pair<long long int, long long int>&'}
  686 |       erase(const key_type& __x)
      |             ~~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_set.h:708:7: note: candidate: 'std::set<_Key, _Compare, _Alloc>::iterator std::set<_Key, _Compare, _Alloc>::erase(const_iterator, const_iterator) [with _Key = std::pair<long long int, long long int>; _Compare = std::less<std::pair<long long int, long long int> >; _Alloc = std::allocator<std::pair<long long int, long long int> >; iterator = std::_Rb_tree<std::pair<long long int, long long int>, std::pair<long long int, long long int>, std::_Identity<std::pair<long long int, long long int> >, std::less<std::pair<long long int, long long int> >, std::allocator<std::pair<long long int, long long int> > >::const_iterator; const_iterator = std::_Rb_tree<std::pair<long long int, long long int>, std::pair<long long int, long long int>, std::_Identity<std::pair<long long int, long long int> >, std::less<std::pair<long long int, long long int> >, std::allocator<std::pair<long long int, long long int> > >::const_iterator]'
  708 |       erase(const_iterator __first, const_iterator __last)
      |       ^~~~~
/usr/include/c++/14/bits/stl_set.h:708:7: note:   candidate expects 2 arguments, 1 provided