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 = 1000000;
int tree[4 * N];
int 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++;
    }
    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 = query[i] + MOD;
    	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 'void update(int, int, int, int, int, long long int)':
a.cc:69:34: error: no matching function for call to 'min(int&, long long int&)'
   69 |                 tree[node] = min (tree[node], val);
      |                              ~~~~^~~~~~~~~~~~~~~~~
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:3:
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
a.cc:69:34: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   69 |                 tree[node] = min (tree[node], val);
      |                              ~~~~^~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281: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:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note:   template argument deduction/substitution failed:
a.cc:69:34: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   69 |                 tree[node] = min (tree[node], val);
      |                              ~~~~^~~~~~~~~~~~~~~~~
a.cc:71:48: error: no matching function for call to 'min(int&, long long int&)'
   71 |                         lazy[node + node] = min(lazy[node + node], val);
      |                                             ~~~^~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
a.cc:71:48: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   71 |                         lazy[node + node] = min(lazy[node + node], val);
      |                                             ~~~^~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:   candidate expects 3 arguments, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note:   template argument deduction/substitution failed:
a.cc:71:48: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   71 |                         lazy[node + node] = min(lazy[node + node], val);
      |                                             ~~~^~~~~~~~~~~~~~~~~~~~~~~~
a.cc:72:53: error: no matching function for call to 'min(int&, long long int&)'
   72 |                         lazy[node + node + 1] = min (lazy[node + node + 1], val);
      |                                                 ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
a.cc:72:53: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   72 |                         lazy[node + node + 1] = min (lazy[node + node + 1], val);
      |                                                 ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:   candidate expects 3 arguments, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note:   template argument deduction/substitution failed:
a.cc:72:53: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   72 |                         lazy[node + node + 1] = min (lazy[node + node + 1], val);
      |                                                 ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~