//teja349 #include #include #include #include #include #include #include #include #include #include #include #include #include #include //setbase - cout << setbase (16); cout << 100 << endl; Prints 64 //setfill - cout << setfill ('x') << setw (5); cout << 77 << endl; prints xxx77 //setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx //cout.precision(x) cout<=b;i--) #define pb push_back #define mp make_pair #define vi vector< int > #define vl vector< ll > #define ss second #define ff first #define ll long long #define pii pair< int,int > #define pll pair< ll,ll > #define sz(a) a.size() #define inf (1000*1000*1000+5) #define all(a) a.begin(),a.end() #define tri pair #define vii vector #define vll vector #define viii vector #define mod (1000*1000*1000+7) #define pqueue priority_queue< int > #define pdqueue priority_queue< int,vi ,greater< int > > //std::ios::sync_with_stdio(false); ll bit[512345],maxn=512345; ll update(ll pos,ll val){ while(pos0){ ans+=bit[pos]; pos-=pos&(-pos); } return ans; } mapmapi; ll x[212345],p[212345],y[112345],r[112345],st[112345],en[123456]; ll valid[212345]; int main(){ std::ios::sync_with_stdio(false); ll n; cin>>n; ll i; rep(i,n){ cin>>p[i]; } rep(i,n){ cin>>x[i]; mapi[x[i]]=0; } ll m; cin>>m; rep(i,m){ cin>>y[i]; } rep(i,m){ cin>>r[i]; mapi[y[i]-r[i]]=0; mapi[y[i]+r[i]]=0; } ll counter =1; map::iterator it; for(it=mapi.begin();it!=mapi.end();it++){ it->ss=counter++; } rep(i,n){ x[i]=mapi[x[i]]; } rep(i,m){ st[i]=mapi[y[i]-r[i]]; en[i]=mapi[y[i]+r[i]]; update(st[i],1); update(en[i]+1,-1); } rep(i,n){ valid[i]=query(x[i]); } rep(i,maxn){ bit[i]=0; } ll ans=0; rep(i,n){ if(valid[i]==1) update(x[i],p[i]); if(!valid[i]) ans+=p[i]; } ll maxi=0; rep(i,m){ maxi=max(maxi,query(en[i])-query(st[i]-1)); } ans+=maxi; cout<