#include using namespace std; using lint = long long int; using pint = pair; using plint = pair; struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_; #define ALL(x) (x).begin(), (x).end() #define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i=i##_begin_;i--) #define REP(i, n) FOR(i,0,n) #define IREP(i, n) IFOR(i,0,n) template bool chmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; } template bool chmin(T &m, const T q) { if (m > q) {m = q; return true;} else return false; } template istream &operator>>(istream &is, vector &vec){ for (auto &v : vec) is >> v; return is; } template ostream &operator<<(ostream &os, const vector &vec){ os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; } template ostream &operator<<(ostream &os, const deque &vec){ os << "deq["; for (auto v : vec) os << v << ","; os << "]"; return os; } template ostream &operator<<(ostream &os, const pair &pa){ os << "(" << pa.first << "," << pa.second << ")"; return os; } #define dbg(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ") " << __FILE__ << endl; void No() { puts("NO"); exit(0); } int main() { int N, M; cin >> N >> M; vector A(M); cin >> A; vector> TS(M); int Q; cin >> Q; REP(t, Q) { int b; cin >> b; TS[b - 1].emplace_back(t + 1); } vector hist_prev{{{0, 0}}}; REP(i, A.size()) { priority_queue, greater> pq; for (auto x : hist_prev) pq.push(x); for (auto t : TS[i]) pq.emplace(t, -1); using P = pair; vector

hist{{0, {A[i], A[i]}}}; int prev_now = (i ? A[i - 1] : 0); while (pq.size()) { auto [t, x] = pq.top(); pq.pop(); if (x == -1) { auto [l, r] = hist.back().second; l--, r++; while (l <= prev_now) l += 2; hist.emplace_back(t, pint(l, r)); } else { prev_now = x; int &l = hist.back().second.first; while (l <= prev_now) l += 2; } } vector hist_next(hist.size()); IREP(i, hist.size()) { if (hist[i].second.first > hist[i].second.second or hist[i].second.first > N) No(); if (i) { chmax(hist[i - 1].second.first, hist[i].second.first - 1); chmin(hist[i - 1].second.second, hist[i].second.second + 1); } hist_next[i] = make_pair(hist[i].first, hist[i].second.first); } hist_prev = hist_next; } puts("YES"); }