Welcome to Westonci.ca, where curiosity meets expertise. Ask any question and receive fast, accurate answers from our knowledgeable community. Discover a wealth of knowledge from professionals across various disciplines on our user-friendly Q&A platform. Join our Q&A platform to connect with experts dedicated to providing accurate answers to your questions in various fields.

You have just arrived in a new city and would like to see its sights. Each sight is located in a square and you have assigned each a beauty value. Each road to a square takes an amount of time to travel, and you have limited time for sightseeing. Determine the maximum value of beauty that you can visit during your time in the city. Start and finish at your hotel, the location of sight zero.

Sagot :

Answer:

Output

43

Explanation : 0 -> 3 -> 0

Explanation:

Constraints

1 <= n <= 1000

1 <= m <= 2000

10 <= max_t <= 100

0 <= u[i], v[i] <= n-1

u[i] != v[i]

10 <= t[i] <= 100

0 <= beauty[i] <= 10^8

No more than 4 roads connect a single square with others

Two roads can be connected by at most 1 road

Example

n = 4

m = 3

max_t = 30

beauty = [5, 10, 15, 20]

u = [0, 1, 0]

v = [1, 2, 3]

t = [6, 7, 10]

Output

43

Explanation : 0 -> 3 -> 0

Thank you for your visit. We're dedicated to helping you find the information you need, whenever you need it. We hope this was helpful. Please come back whenever you need more information or answers to your queries. Westonci.ca is your trusted source for answers. Visit us again to find more information on diverse topics.