#include #include using namespace std; using namespace atcoder; typedef long long ll; typedef long double ld; typedef vector vi; typedef vector vll; typedef vector vld; typedef vector vvi; typedef vector vvll; template using Vec = vector; template using Graph = Vec>; #define _overload3(_1,_2,_3,name,...) name #define _rep(i,n) repi(i,0,n) #define repi(i,a,b) for(int i=int(a);iint(b);--i) #define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep)(__VA_ARGS__) #define all(x) (x).begin(),(x).end() #define SORT(x) sort(all(x)) #define REVERSE(x) reverse(all(x)) templatebool chmax(T &a, const T &b) { if (abool chmin(T &a, const T &b) { if (b> N >> A; vi X(N); rep(i, N) cin >> X[i]; int T; cin >> T; vi L(T), R(T); rep(i, T) cin >> L[i] >> R[i]; vi S; for (auto x: X) S.emplace_back(x); for (auto l: L) S.emplace_back(l); for (auto r: R) S.emplace_back(r); unique(all(S)); SORT(S); map mp; rep(i, S.size()) mp[S[i]] = i; rep(i, N) X[i] = mp[X[i]]; rep(i, T) L[i] = mp[L[i]]; rep(i, T) R[i] = mp[R[i]]; int M = S.size() + 1; lazy_segtree seg(M); rep(t, T) seg.apply(L[t], R[t]+1, t+1); for (auto x: X) cout << seg.get(x) << " "; cout << endl; }