Language: C++

#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
#include <complex>
#include <cmath>
#include <array>
#include <numeric>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
//#define mod 998244353
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pint> vpint;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=200050;
//templete
// 区間更新、区間最小の遅延セグメントツリー
struct RMQRUQ {
  int n;
  vector<int> dat, lazy;
 
  RMQRUQ(){}
  RMQRUQ(int n_) {
    n = 1; while(n < n_) n *= 2;
    dat.assign(n*2, INT_MAX);
    lazy.assign(n*2, INT_MAX);
  }
 
  void eval(int len, int k) {
    if(lazy[k] == INT_MAX) return;
    if(k*2+1 < n*2-1) {
      lazy[2*k+1] = lazy[k];
      lazy[2*k+2] = lazy[k];
    }
    dat[k] = lazy[k];
    lazy[k] = INT_MAX;
  }
 
  // [a, b)
  ll update(int a, int b, ll x, int k, int l, int r) {
    eval(r-l, k);
    if(b <= l || r <= a) return dat[k];
    if(a <= l && r <= b) {
      lazy[k] = x;
      return lazy[k];
    }
    return dat[k] = min(update(a, b, x, 2*k+1, l, (l+r)/2), update(a, b, x, 2*k+2, (l+r)/2, r));
  }
  ll update(int a, int b, ll x) { return update(a, b, x, 0, 0, n); }
 
  // [a, b)
  ll query(int a, int b, int k, int l, int r) {
    eval(r-l, k);
    if(b <= l || r <= a) return INT_MAX;
    if(a <= l && r <= b) return dat[k];
    ll vl = query(a, b, 2*k+1, l, (l+r)/2);
    ll vr = query(a, b, 2*k+2, (l+r)/2, r);
    return min(vl, vr);
  }
  ll query(int a, int b) { return query(a, b, 0, 0, n); }
};
int main() {
	int N,Q;
	cin>>N>>Q;
	vector<tint> kouji;
	for(int i=0;i<N;i++){
		int S,T,X;
		cin>>S>>T>>X;
		kouji.eb(X,S,T);
	}
	vpint D;
	for(int i=0;i<Q;i++){
		int d;
		cin>>d;
		D.eb(d,i);
	}
	sort(D.begin(),D.end());
	sort(kouji.begin(),kouji.end());
	reverse(kouji.begin(),kouji.end());
	RMQRUQ Seg(Q+1);
	for(tint T:kouji){
		int s,t,x;
		tie(x,s,t)=T;
		s=max(0,s-x);
		t=max(0,t-x);
		//[s,t)に効果あり
		if(t==0)
			continue;
		//範囲に入っているindexを二分探索する
		int l=lower_bound(D.begin(),D.end(),mp(s,0))-D.begin();
		int r=upper_bound(D.begin(),D.end(),mp(t,0))-D.begin();
		Seg.update(l,r,x);

	}
	int ans[SIZE]={};

	for(int i=0;i<Q;i++){
		int temp=Seg.query(i,i+1);
		if(temp==INT_MAX)
			cout<<-1<<endl;
		else
			cout<<temp<<endl;
	}
    return 0;
}

Compiler output:
a.cc: In constructor 'RMQRUQ::RMQRUQ(int)':
a.cc:57:21: error: 'INT_MAX' was not declared in this scope
   57 |     dat.assign(n*2, INT_MAX);
      |                     ^~~~~~~
a.cc:26:1: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
   25 | #include <numeric>
  +++ |+#include <climits>
   26 | using namespace std;
a.cc: In member function 'void RMQRUQ::eval(int, int)':
a.cc:62:19: error: 'INT_MAX' was not declared in this scope
   62 |     if(lazy[k] == INT_MAX) return;
      |                   ^~~~~~~
a.cc:62:19: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
a.cc:68:15: error: 'INT_MAX' was not declared in this scope
   68 |     lazy[k] = INT_MAX;
      |               ^~~~~~~
a.cc:68:15: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
a.cc: In member function 'll RMQRUQ::query(int, int, int, int, int)':
a.cc:86:33: error: 'INT_MAX' was not declared in this scope
   86 |     if(b <= l || r <= a) return INT_MAX;
      |                                 ^~~~~~~
a.cc:86:33: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
a.cc: In function 'int main()':
a.cc:131:26: error: 'INT_MAX' was not declared in this scope
  131 |                 if(temp==INT_MAX)
      |                          ^~~~~~~
a.cc:131:26: note: 'INT_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'