Language: C++

/**
 *    author  : 𝒌𝒚𝒐𝒎𝒖𝒌𝒚𝒐𝒎𝒖𝒑𝒖𝒓𝒊𝒏
 *    created : 2020-01-26 11:39:26
**/

#include <iostream>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
#include <bitset>
#include <cassert>
#include <cctype>
#include <iomanip>
#include <random>
#include <utility>
#include <chrono>

using namespace std;

using int64 = long long;

template<class T> std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) { os << '{'; size_t n = vec.size(); for (size_t i = 0; i < n; ++i) { os << vec[i]; if (i != n - 1) os << ','; } os << '}'; return os; }
template<class T, class U> std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) { return os << '{' << p.first << " " << p.second << '}'; }
template<class T, class U> std::ostream& operator<<(std::ostream& os, const std::map<T, U>& mp) { for (auto it = mp.begin(); it != mp.end(); ++it) { os << '{' << it->first << ':' << it->second << '}'; if (it != --mp.end()) os << ','; } return os; }
template<class T> std::ostream& operator<<(std::ostream& os, const std::set<T>& st) { os << '{'; for (auto it = st.begin(); it != st.end(); ++it) { os << *it; if (it != --st.end()) os << ','; } os << '}'; return os; }
template<class T> std::istream& operator>>(std::istream& is, std::vector<T>& vec) { size_t n = vec.size(); for (size_t i = 0; i < n; ++i) is >> vec[i]; return is; }

#define all(_) begin(_), end(_)
#define rall(_) rbegin(_), rend(_)

#ifdef LOCAL
#define debug(_) cerr << #_ << ": " << (_) << '\n'
#define getchar_unlocked getchar
#else
#define debug(_) 1728
#endif

template <class Monoid, class Function>
class LazySegmentTree {
  using OperatorMonoid = Monoid;

 public:
  LazySegmentTree(const std::vector<Monoid>& data, Monoid identity_element,
                  Function function)
      : identity_element_(identity_element),
        operator_identity_element_(static_cast<OperatorMonoid>(-1)),
        data_(data),
        function_(function) {
    Build();
  }

  // update range [left, right)
  void RangeUpdate(int left, int right, OperatorMonoid new_value) {
    Thrust(left += n_);
    Thrust(right += n_ - 1);
    for (int l = left, r = right + 1; l < r; l >>= 1, r >>= 1) {
      if (l & 1) lazy_[l] = new_value, ++l;
      if (r & 1) --r, lazy_[r] = new_value;
    }
    Recalc(left);
    Recalc(right);
  }

  // return Query[left, right)
  Monoid Query(int left, int right) {
    Thrust(left += n_);
    Thrust(right += n_ - 1);
    Monoid L = identity_element_, R = identity_element_;
    for (int l = left, r = right + 1; l < r; l >>= 1, r >>= 1) {
      if (l & 1) L = function_(L, Reflect(l++));
      if (r & 1) R = function_(Reflect(--r), R);
    }
    return function_(L, R);
  }

  Monoid operator[](int position) { return Query(position, position + 1); }

 private:
  size_t n_;
  size_t height_;
  Monoid identity_element_;
  OperatorMonoid operator_identity_element_;
  std::vector<Monoid> data_;
  std::vector<Monoid> node_;
  std::vector<OperatorMonoid> lazy_;
  Function function_;

  void Build() {
    size_t SIZE = data_.size();
    n_ = 1;
    height_ = 0;
    while (n_ < SIZE) {
      n_ <<= 1;
      ++height_;
    }
    node_.assign(2 * n_, identity_element_);
    lazy_.assign(2 * n_, operator_identity_element_);
    for (size_t i = 0; i < SIZE; ++i) {
      node_[i + n_] = data_[i];
    }
    for (size_t i = n_ - 1; i > 0; --i) {
      node_[i] = function_(node_[2 * i], node_[2 * i + 1]);
    }
  }

  inline void Propagate(int k) {
    if (lazy_[k] != operator_identity_element_) {
      lazy_[2 * k] = lazy_[k];
      lazy_[2 * k + 1] = lazy_[k];
      node_[k] = Reflect(k);
      lazy_[k] = operator_identity_element_;
    }
  }

  inline Monoid Reflect(int k) {
    return lazy_[k] == operator_identity_element_ ? node_[k] : lazy_[k];
  }

  inline void Recalc(int k) {
    while (k >>= 1) node_[k] = function_(Reflect(2 * k), Reflect(2 * k + 1));
  }

  inline void Thrust(int k) {
    for (size_t i = height_; i > 0; i--) Propagate(k >> i);
  }
};

constexpr int64 INF = 1e18;

struct task {
  int64 s, t, x;
};

template<class T> inline void fastin(T &num) {
  bool negative = false;
  T c;
  num = 0;
  c = getchar_unlocked();
  if (c == '-') {
    negative = true;
    c = getchar_unlocked();
  }
  for (; (c > 47 && c < 58); c = getchar_unlocked()) num = (num << 3) + (num << 1) + c - 48;
  if (negative) num *= -1;
}

int main() {
  //ios_base::sync_with_stdio(false);
  //cin.tie(nullptr);

  int n, q; fastin(n); fastin(q);

  vector<int64> v;
  vector<int64> s(n), t(n), x(n);
  vector<task> v2;
  for (int i = 0; i < n; ++i) {
    fastin(s[i]); fastin(t[i]); fastin(q[i]);
    v.emplace_back(s[i] - x[i]);
    v.emplace_back(t[i] - x[i]);
    v2.push_back((task){s[i] - x[i], t[i] - x[i], x[i]});
  }

  vector<int64> d(q);
  for (int i = 0; i < q; ++i) {
    fastin(d[i]);
    v.emplace_back(d[i]);
  }

  sort(v2.begin(), v2.end(), [](const task& p, const task& q){
    return p.x > q.x;
  });

  sort(all(v));
  v.erase(unique(all(v)), v.end());

  auto f = [](int64 x, int64 y){ return min(x, y); };
  LazySegmentTree<int64, decltype(f)> seg(vector<int64>(1000000, INF), INF, f);
  
  for (int i = 0; i < n; ++i) {
    int ss = lower_bound(all(v), v2[i].s) - v.begin();
    int tt = lower_bound(all(v), v2[i].t) - v.begin();
    seg.RangeUpdate(ss, tt, v2[i].x);
  }

  for (int i = 0; i < q; ++i) {
    int dd = lower_bound(all(v), d[i]) - v.begin();
    if (seg[dd] == INF) {
      //cout << -1 << '\n';
      printf("%d\n", -1);
    } else {
      //cout << seg[dd] << '\n';
      printf("%lld\n", seg[dd]);
    }
  }

  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:165:41: error: invalid types 'int[int]' for array subscript
  165 |     fastin(s[i]); fastin(t[i]); fastin(q[i]);
      |                                         ^