Language: C++

//----------ACCIDENTAL COMPETITIVE PROGRAMMER---------------------

#include<bits/stdc++.h>

/*
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
*/
using namespace std;

#define LL long long
#define LD long double
#define PB push_back
#define MP make_pair


const LL MOD = (1e9) + 7 ;
const LD EPS = 0.0000001 ;

struct node {
	int s; int t; int x;
};

bool comp(const node a, const node b)
{
	return a.x < b.x;
}

const int N = 500000;
LL tree[4 * N];
LL lazy[4 * N];

void build (int node, int l, int r)
{
	if (l > r)
		return ;
	if (l == r){
		tree[node] = INT_MAX;
		return ;
	}
	int mid = (l + r) / 2;
	int left = 2 * node;
	int right = left + 1;
	build (left, l, mid);
	build (right, mid + 1, r);
	tree[node] = min(tree[left], tree[right]);
}

void propagate(int node, int l, int r)
{
	if (lazy[node] != INT_MAX){
		tree[node] = min (tree[node], lazy[node]);
		if (l != r){
			lazy[node + node] = min(lazy[node + node], lazy[node]);
			lazy[node + node + 1] = min (lazy[node + node + 1], lazy[node]); 
		}
		lazy[node] = INT_MAX;
	}
}

void update(int node, int l, int r, int a, int b, LL val)
{
	propagate(node, l, r);
	if (l > r  || a > b || l > b || r < a)
		return ;
	if (a <= l && r <= b){
		tree[node] = min (tree[node], val);
		if (l != r){
			lazy[node + node] = min(lazy[node + node], val);
			lazy[node + node + 1] = min (lazy[node + node + 1], val);
		}
		return ;
	}
	int mid = (l + r) / 2;
	int left = node + node;
	int right = left + 1;
	update(left, l, mid, a, b, val);
	update(right, mid + 1, r, a, b ,val);
	tree[node] = min (tree[left], tree[right]);
}

LL queryy(int node, int l, int r, int x)
{
	propagate(node, l, r);
	if (l > r || l > x || r < x)
		return INT_MAX;
	if (l == r)
	{
		return tree[node];
	}
	int mid = (l + r) / 2;
	int left = node + node;
	int right = left + 1;
	LL a = queryy(left, l, mid, x);
	LL b = queryy(right, mid + 1, r, x);
	//tree[node] = min (tree[left], tree[right]);
	return min(a, b);
}

int main(void)
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n, q; cin >> n >> q;
    node arr[n];
    for (int i = 0; i < n; i++){
    	cin >> arr[i].s;
    	cin >> arr[i].t;
    	cin >> arr[i].x;
    	arr[i].t--;
    }
    int query[q];
    for (int i = 0; i < q; i++)
    	cin >> query[i];

    set<LL> distinct;
    /*for (int i = 0; i < n; i++)
    	distinct.insert(arr[i].x);*/
    for (int i = 0; i < q; i++)
    	distinct.insert(query[i] + MOD);
    for (int i = 0; i < n; i++){
    	distinct.insert(arr[i].s - arr[i].x + MOD);
    	distinct.insert(arr[i].t - arr[i].x + MOD);
    }

    int cnt = 0;
    map<LL,LL> hashed;
    map<LL,LL> hashedTo;
    for (auto it : distinct){
    	hashed[it] = cnt++;
    	hashedTo[cnt - 1] = it;
    }
    cnt--;
    sort(arr, arr + n, comp);
    build (1, 0, cnt);
    for (int i = 0; i < 4 * N; i++)
        lazy[i] = INT_MAX;
    for (int i = 0; i < n; i++){
    	int x = arr[i].s - arr[i].x + MOD;
    	int y = arr[i].t - arr[i].x + MOD;
    	update(1, 0, cnt, hashed[x], hashed[y], i);
    }

    for (int i = 0; i < q; i++){
    	int tim = queryy[i];
    	LL x = queryy(1, 0, cnt, hashed[tim]);
    	if (x == INT_MAX)
    		cout << "-1" << endl;
    	else
    		cout << arr[x].x << endl;
    }


	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:148:27: warning: pointer to a function used in arithmetic [-Wpointer-arith]
  148 |         int tim = queryy[i];
      |                           ^
a.cc:148:27: error: invalid conversion from 'long long int (*)(int, int, int, int)' to 'int' [-fpermissive]
  148 |         int tim = queryy[i];
      |                           ^
      |                           |
      |                           long long int (*)(int, int, int, int)