eolymp
bolt
Попробуйте наш новый интерфейс для отправки задач
Задачи

Network Planning

Network Planning

In petroleum retail industry, the locations of service stations are very important to the profit of their company. To maximize the profit, the company uses the concept of "Network Planning" to choose where to build new service stations. You are a consultant of this company. This company gives you the data which consists of the number of cities and how are they connected, number of liters of fuel demand, list of cities that already had a service station, and a total number of new service stations to be constructed in their plan this year. Of course, the result that they need from you is "which cities should they construct new service stations to maximize their profit". Sounds simple, isn’t it? Here is a list of what you might need to know. \begin{itemize} \item There will be N cities in this country. Each city can own only one service station. \item Assuming each service station is able to supply unlimited fuel demand. \item Each service station will supply \textbf{70}\% of fuel demand (in liters) within its city, plus \textbf{10}\% of each neighboring city’s demand regardless of a fact that whether neighboring cities have their own service station or not. \item For example, if \textbf{City A}, \textbf{City B}, and \textbf{City C} are all connected; \textbf{City A} and \textbf{City B} has their own service stations, then \textbf{City A} will supply \textbf{70}\% fuel demand of itself plus \textbf{10}\% from \textbf{City B} and \textbf{10}\% from \textbf{City C}. So does \textbf{City B}. \item Due to geographical constraints, each city will have no more than three neighboring cities. \item Last, but not least, their total revenue is a direct variation of total fuel demand that they can supply. \end{itemize} \InputFile First line of input is a number of test cases \textbf{T} ≤ \textbf{10}. Each test case start with the number of cities \textbf{N} (\textbf{1} ≤ \textbf{N} ≤ \textbf{100000}). Following \textbf{N} lines has an Integer \textbf{D_i} (\textbf{0} ≤ \textbf{D_i} ≤ \textbf{1000}) the fuel demand in each city. Next line contains an integer \textbf{E} number of edges. Following \textbf{E} lines has \textbf{2} integers \textbf{C_1} and \textbf{C_2}, describe bi-directionally neighboring cities. There will not be any duplicated edges in the input (i.e. if there is an edge for (\textbf{C_1}, \textbf{C_2}), there will not be an edge for (\textbf{C_2}, \textbf{C_1}) in the same input set). Also note that all cities will be numbering from \textbf{1} to \textbf{N}. Next line contains an integer \textbf{S} (\textbf{0} ≤ \textbf{S} < \textbf{N}) the number of existing service stations. Following \textbf{S} lines has an integer \textbf{C} the city which already owned service station. Last line contains an integer \textbf{M} (\textbf{1} ≤ \textbf{M} ≤ \textbf{N--S}) an exact number of new service stations they must construct this year. \textbf{Ouput} For each test case, display two lines of output. First line display a positive integer (using general rounding rules) the maximum total fuel demand they can supply including from both existing service stations and new service stations at the optimal cities. Second line display a list of the optimal cities that they must construct new service stations, given space-separated and in increasing order. The cities with existing service stations are not counted into this list. If there is more than one possible solution, output the one that is first in lexicographical order. \textit{\textbf{Illustration for this example}} First Example In this illustration, you will see that if they construct a new service station in \textbf{City 3} only, it will maximize the total supply to \textbf{360} liters. \includegraphics{https://static.e-olymp.com/content/54/54852d76f9d522043b01ba15f0317e076762cbae.jpg} The second example In this example, there are two best solutions. Constructing new stations in city 1, city 2 and city 5 will give the same profit as constructing new stations in city 1, city 3 and city 5. We must answer 1 2 5 because it appear first in lexicographical order. The total supply will be 268.2 for the city 1, 182.6 for the city 2 and 290 for the city 5. The city 4 which we already have a service station supplies 150 liters. The total supply is 268.2 + 182.6 + 290 + 150 = 890.8. This is rounded to 891. \includegraphics{https://static.e-olymp.com/content/21/2153b9ab9a09dbaa10f62a6e343a9cb769bc138a.jpg}
Лимит времени 1 секунда
Лимит использования памяти 64 MiB
Входные данные #1
2
3
100
200
300
3
1 2
2 3
3 1
1
1
1
5
326
200
200
100
400
5
1 2
1 3
2 4
3 4
4 5
1
4
3
Выходные данные #1
360
3
891
1 2 5
Источник ACM ICPC Asia Thailand National programming Contest 2013