| Cataratas do Pinhão 2025 |
|---|
| Finished |
Thiago is a tourist exploring the wonderful city of Curitiba, in Paraná, famous for its beauty (and cold weather). The map of the region can be represented by $$$N$$$ locations and $$$M$$$ roads connecting them. Each road has an associated travel time, in minutes.
Thiago wants to visit $$$P$$$ tourist attractions, which are the first $$$P$$$ locations on his map, such as the Botanical Garden, the Oscar Niemeyer Museum, and the huge UFPR. For each of these attractions, he has assigned a value of "happiness" that he would feel when visiting them for the first time.
Unfortunately, his time is short. He has only one day for his tour, which starts at 8:00 a.m. at his hotel (located at location $$$N$$$) and must end before midnight (12:00 a.m.). The time to visit each location depends on the tourist attraction to be visited. He can visit the tourist attractions in any order he wants and does not need to return to the hotel.
As a close friend of Thiago's and a skilled programmer, you have decided to assist him. Your task is to develop a program that determines the optimal route for Thiago, that is, the maximum sum of happiness from the locations visited without exceeding the time limit.
The first line of the input contains four integers: the number of locations $$$N$$$ ($$$2 \le N \le 2 \times 10^{5}$$$), the number of roads $$$M$$$ ($$$N-1 \le M \le 2 \times 10^{5}$$$), and the number of tourist attractions $$$P$$$ ($$$1 \le P \le 20$$$). It is guaranteed that the graph is connected and that $$$P \lt N$$$.
The next $$$M$$$ lines describe the roads in the city. Each line contains three integers $$$u$$$, $$$v$$$, and $$$w$$$, where $$$u$$$ and $$$v$$$ ($$$1 \le u,v \le N$$$) represent the locations connected by the road, and $$$w$$$ ($$$1 \le w \le 180$$$) represents the travel time in minutes. The roads are two-way, and there are no repeated roads or roads with $$$u = v$$$ in the input.
The next line contains $$$P$$$ distinct integers $$$f_1, f_2,\ldots,f_P$$$ where each $$$f_i$$$ ($$$1 \le f_i \le 10^5$$$) represents the happiness Thiago gets from visiting tourist spot $$$i$$$ for the first time.
The last line of the input contains $$$P$$$ integers $$$t_1, t_2,\ldots,t_p$$$ where $$$t_i$$$ ($$$1 \le t_i \le 120$$$) represents the time spent, in minutes, at tourist attraction $$$i$$$.
Output a single integer, the maximum amount of happiness that Thiago can achieve.
4 3 24 1 1001 3 1503 2 5050 8030 40
130
8 10 48 6 1206 1 1501 2 1002 3 1703 4 1804 7 907 5 1106 4 1601 7 1708 5 130100 60 70 80120 60 80 40
250
5 4 35 4 1705 1 1704 2 1702 3 100160 120 110120 120 120
280
| Name |
|---|


