#include using namespace std; long maximumPeople(vector town_population, vector town_loc, vector cloud_loc, vector cloud_range) { int biggest_dark_towns = 0; int cloudy_population = 0; for (int i = 0; i < cloud_loc.size(); i++) { int cloud_begin = cloud_loc[i] - cloud_range[i]; int cloud_end = cloud_loc[i] + cloud_range[i]; int dark_towns = 0; for (int j = 0; j < town_loc.size(); j++) { if (town_loc[j] >= cloud_begin && town_loc[j] <= cloud_end)//dark { dark_towns+= town_population[j]; cloudy_population += dark_towns; } } if (dark_towns > biggest_dark_towns) biggest_dark_towns = dark_towns; } int sum = 0; for (int i = 0; i < town_population.size(); i++) sum += town_population[i]; int sunny_people = sum - (cloudy_population - biggest_dark_towns); return sunny_people; } 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; }