Language: C++

#include<Windows.h>

#include <stdio.h>
#include <algorithm>
#include <vector>
#include <string>
const long long mod = 1000000007;

struct D {
	int t, s = -1;
	bool operator<(const int o)const {
		return t < o;
	}
	bool operator==(const int o)const {
		return t == o;
	}
};

struct STX
{
	int s, t, x;
	bool operator<(const STX&o)const {
		return x < o.x;
	}
};

template<class T>
class ErasableSortedArray {

	int n;
	int level;
	T* data;
	int *prev, *next;
	bool *eraced;
	int **ctree;

public:
	ErasableSortedArray(T* data, int n) :data(data), n(n) {
		for (int i = 0; i < 31; i++) {
			if (n >> i == 0) {
				level = i + 1;
				break;
			}
		}
		ctree = new int*[level];
		for (int i = 0; i < level; i++) {
			ctree[i] = new int[((n - 1) >> i) + 1];
			for (int j = 0; j < ((n - 1) >> i) + 1; j++) {
				if (i == 0)ctree[0][j] = 1;
				else {
					if ((j << i) + (1 << (i - 1)) >= n) {
						ctree[i][j] = ctree[i - 1][j << 1];
					}
					else {
						ctree[i][j] = ctree[i - 1][j << 1] + ctree[i - 1][(j << 1) + 1];
					}
				}
			}
		}
		prev = new int[n];
		next = new int[n];
		eraced = new bool[n];
		for (int i = 0; i < n; i++) {
			prev[i] = i - 1;
			next[i] = i + 1;
			eraced[i] = false;
		}
	}
	~ErasableSortedArray() {
		for (int i = 0; i < level; i++) {
			delete[] ctree[i];
		}
		delete[] ctree;
		delete[] prev;
		delete[] next;
	}

	T& operator[](int i) {
		return data[i];
	}

	int Next(int i) {
		if (!eraced[i])next[i];
		for (int l = 1; l < level; l++) {
			if (i&(1 << (l - 1)) == 0) {
				if (ctree[l][i >> l] != ctree[l - 1][i >> (l - 1)]) {
					int r = (i >> (l - 1)) + 1;
					for (int m = l - 2; m >= 0; m--) {
						r <<= 1;
						if (ctree[m][r] == 0) {
							r |= 1;
						}
					}
					return r;
				}
			}
		}
		return n;
	}

	int Prev(int i) {
		if (!eraced[i])prev[i];
		for (int l = 1; l < level; l++) {
			if (i&(1 << (l - 1)) == 1) {
				if (ctree[l][i >> l] != ctree[l - 1][i >> (l - 1)]) {
					int r = (i >> (l - 1));
					for (int m = l - 2; m >= 0; m--) {
						r <<= 1;
						if (ctree[m][r | 1] != 0) {
							r |= 1;
						}
					}
					return r;
				}
			}
		}
		return -1;
	}

	void Erace(int i) {
		if (eraced[i])return;
		eraced[i] = true;
		for (int l = 0; l < level; l++) {
			ctree[l][i >> l]--;
		}
	}

	template<class T2>
	int Search(T2 t, char mode = 'j') {
		int r = 0;
		for (int i = 20; i >= 0; i--) {
			int c = r + (1 << i);
			if (c >= n)continue;
			if (data[c] < t)r = c;
		}
		if (data[r] == t && !eraced[r]) {
			return r;
		}
		switch (mode) {
		case 'p':
			return Prev(r);
		case 'n':
			return Next(Prev(r));
		default:
			return -1;
		}
	}

};


int getint() {
	int r;
	scanf("%d", &r);
	return r;
}

int main() {
	int N = getint();
	int Q = getint();
	STX *stx = new STX[N];
	for (int i = 0; i < N; i++) {
		stx[i].s = getint();
		stx[i].t = getint();
		stx[i].x = getint();
	}
	D *ds = new D[Q];
	for (int i = 0; i < Q; i++) {
		ds[i].t = getint();
	}
	ErasableSortedArray<D> d(ds, Q);
	std::sort(stx, stx + N);
	for (int i = 0; i < N; i++) {
		int c = d.Search(stx[i].s - stx[i].x, 'n');
		for (int j = c; d[j] < stx[i].t - stx[i].x;) {
			int n = d.Next(j);
			d[j].s = stx[i].x;
			d.Erace(j);
			j = n;
			if (j == Q)break;
		}
	}
	for (int i = 0; i < Q; i++) {
		printf("%d\n", ds[i].s);
	}
	Sleep(100000);
	return 0;
}

Compiler output:
a.cc:1:9: fatal error: Windows.h: No such file or directory
    1 | #include<Windows.h>
      |         ^~~~~~~~~~~
compilation terminated.