Concert
题号:NC273398
时间限制:C/C++/Rust/Pascal 1秒,其他语言2秒
空间限制:C/C++/Rust/Pascal 256 M,其他语言512 M
64bit IO Format: %lld

题目描述

Alice is a lead singer in a band. Her band is on a tour, holding concerts every month. However, they don't want to stay in the same city for two consecutive months. Therefore, at the end of each month, the band will move to a city adjacent to the current one. There are a total of n cities, connected by m roads, and holding a concert in the i-th city for a month can generate revenue of a_i.

Alice's home is in the first city, so the band will hold the first concert there. The concert tour lasts for k months in total, and Alice wants to return to the first city for the final concert in the k-th month. In other words, in the k-th month, Alice must be in the first city.

Now, Alice wants to know how much revenue she can maximize during the k months.

输入描述:

The first line contains three integers n, m, k (1 \leq n, m, k \leq 5000), as described in the problem statement.
The second line contains n integers ai (1\leq a_i \leq 10^9), representing the revenue Alice can earn by holding a concert in the i-th city for a month.
The next m lines each contain two integers u, v (1 \leq u, v \leq n), indicating there is a bidirectional road between cities u and v.

输出描述:

Output an integer representing the maximum revenue that can be earned. If Alice cannot stay in the first city for the k-th month, output -1.
示例1

输入

复制
3 2 3
1 2 3
1 2
2 3

输出

复制
4
示例2

输入

复制
3 2 2
1 2 3
1 2
2 3

输出

复制
-1