using System; using System.Collections.Generic; using System.IO; using System.Linq; class Solution { static long maximumPeople(int numCities, long[] populations, long[] townLocations, long[] cloudLocations, int numClouds, long[] ranges) { long[] popIfCloudRemoved = new long[numClouds]; for(int i = 0; i < numClouds; i++) { popIfCloudRemoved[i] = CalcPopulation(i, numCities, populations, townLocations, cloudLocations, numClouds, ranges); } return popIfCloudRemoved.Max(); } static long CalcPopulation(int cloudToRemove, int numCities, long[] populations, long[] townLocations, long[] cloudLocations, int numClouds, long[] ranges) { long population = 0; for(int city = 0; city < numCities; city++) { for(int cloud = 0; cloud < numClouds; cloud++) { if(cloud == cloudToRemove) population += populations[city]; else{ if(townLocations[city] > (cloudLocations[cloud] - ranges[cloud]) && townLocations[city] < (cloudLocations[cloud] + ranges[cloud])) population += 0; else population += populations[city]; } } } return population; } static void Main(String[] args) { int n = Convert.ToInt32(Console.ReadLine()); // Numper of towns string[] p_temp = Console.ReadLine().Split(' '); long[] p = Array.ConvertAll(p_temp,Int64.Parse); // The population of each town string[] x_temp = Console.ReadLine().Split(' '); long[] x = Array.ConvertAll(x_temp,Int64.Parse); // The location of each town int m = Convert.ToInt32(Console.ReadLine()); // The number of clouds string[] y_temp = Console.ReadLine().Split(' '); long[] y = Array.ConvertAll(y_temp,Int64.Parse); // The location of each cloud string[] r_temp = Console.ReadLine().Split(' '); long[] r = Array.ConvertAll(r_temp,Int64.Parse); // The range of each cloud long result = maximumPeople(n, p, x, y, m, r); Console.WriteLine(result); } }