#include using namespace std; long maximumPeople(vector p, vector x, vector y, vector r) { // Return the maximum number of people that will be in a sunny town after removing exactly one cloud. long pop = 0, prev = 0, max = 0; for (int i = 0; i < x.size(); i++) { prev = pop; for (int j =0; j < y.size(); j++) { if ((y[j] - r[j] <= x[i]) && (x[i] <= y[j] + r[j])) { pop = p[i]; } if(pop > max) max = pop; } if (prev == pop) max = max + p[i]; } return max; } 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); cout << result << endl; return 0; }