func_code_string: #include <bits/stdc++.h>   using namespace std;   const long long N = 5e5 + 100;   const long long maxN = 6e6;   const long long oo = 1e18;   const long long mod = 998244353;   long long n, m;   long long a[N], b[N], cost[N], equalpos[N];   long long IT[20 * N], lazy[20 * N];   map<long long, long long> mp;   void updmin(long long &x, long long y) { x = min(x, y); }   void addlazy(long long node, long long nlef, long long nrig) {     if (nlef > nrig || !lazy[node]) return;     if (nlef == nrig && IT[node] < oo) IT[node] += lazy[node];     if (nlef < nrig) {       lazy[2 * node] += lazy[node];       lazy[2 * node + 1] += lazy[node];     }     lazy[node] = 0;   }   void upd(long long node, long long nlef, long long nrig, long long lef,            long long rig, long long val, bool flag) {     addlazy(node, nlef, nrig);     if (nlef > rig || nrig < lef || nlef > nrig) return;     if (lef <= nlef && nrig <= rig) {       if (!flag) {         lazy[node] += val;         addlazy(node, nlef, nrig);       } else         IT[node] = val;       return;     }     long long mid = (nlef + nrig) / 2;     upd(2 * node, nlef, mid, lef, rig, val, flag);     upd(2 * node + 1, mid + 1, nrig, lef, rig, val, flag);   }   long long get(long long node, long long nlef, long long nrig, long long pos) {     addlazy(node, nlef, nrig);     if (nlef > pos || pos > nrig) return oo;     if (nlef == nrig) {       return IT[node];     }     long long mid = (nlef + nrig) / 2;     return min(get(2 * node, nlef, mid, pos),                get(2 * node + 1, mid + 1, nrig, pos));   }   signed main() {     ios_base::sync_with_stdio(false);     cout.tie(0);     cin >> n;     for (long long i = 1; i <= n; ++i) cin >> a[i];     for (long long i = 1; i <= n; ++i) cin >> cost[i];     cin >> m;     for (long long i = 1; i <= m; ++i) cin >> b[i], mp[b[i]] = i;     for (long long i = 1; i <= n; ++i)       if (mp.find(a[i]) != mp.end()) equalpos[i] = mp[a[i]];     for (long long i = 0; i <= 20 * N - 1; ++i) IT[i] = oo;     if (a[1] < b[1])       upd(1, 0, m, 0, 0, cost[1], 1);     else if (a[1] == b[1]) {       upd(1, 0, m, 0, 0, cost[1], 1);       upd(1, 0, m, 1, 1, 0, 1);     } else       upd(1, 0, m, 0, 0, cost[1], 1);     for (long long i = 2; i <= n; ++i) {       long long pos = equalpos[i];       if (pos) {         long long val = get(1, 0, m, pos - 1);         long long tmp = get(1, 0, m, pos);         if (cost[i] < 0 && tmp < oo) updmin(val, tmp + cost[i]);         updmin(val, get(1, 0, m, pos));         upd(1, 0, m, pos, pos, val, 1);       }       pos = lower_bound(b + 1, b + m + 1, a[i]) - b - 1;       if (pos >= 0)         upd(1, 0, m, 0, pos, cost[i], 0);       else         pos = 0;       while (pos <= m && b[pos] <= a[i]) pos += 1;       if (cost[i] < 0 && pos <= m) upd(1, 0, m, pos, m, cost[i], 0);     }     long long ans = get(1, 0, m, m);     if (ans < oo) return cout <<  YES n  << ans, 0;     cout <<  NO ;   }   