#include using namespace std; long maximumPeople(vector p, vector x, vector y, vector r,int n,int m) { int i,j; long count[m],max=0; for(i=0;i=y[i]-r[i]&&x[j]<=y[i]+r[i]) count[i]+=p[j]; } if(count[i]>max) max=count[i]; } long sunny=0,temp[n]; for(i=0;i=y[j]-r[j]&&x[i]<=y[j]+r[j]) {temp[i]++; break;} } if(temp[i]==0) sunny+=p[i]; } max+=sunny; return max; // Return the maximum number of people that will be in a sunny town after removing exactly one cloud. } int main() { int n; cin >> n; vector p(n); for(int p_i = 0; p_i < n; p_i++){ cin >> p[p_i]; } vector x(n); for(int x_i = 0; x_i < n; x_i++){ cin >> x[x_i]; } int m; cin >> m; vector y(m); for(int y_i = 0; y_i < m; y_i++){ cin >> y[y_i]; } vector r(m); for(int r_i = 0; r_i < m; r_i++){ cin >> r[r_i]; } long result = maximumPeople(p, x, y, r,n,m); cout << result << endl; return 0; }