数据貌似在不断加强,之前 70pts 的程序现在只有 65pts 了/kel,#7 为什么 WA
// #include <iostream>
// #include <vector>
// using namespace std;
// #define int long long
// const int N = 2510;
// const int M = 10010;
// int n;
// int f[4][N][M];
// int score[N];
// vector<int> v1[N], v[N];
// int read() {
// int x = 0, f = 1;
// char ch = getchar();
// while (ch < '0' || ch > '9') { f = (ch == '-' ? -1 : f); ch = getchar(); }
// while (ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); }
// return x * f;
// }
// void dfs(int x, int fa) {
// if (~fa) v[fa].push_back(x);
// for (int i = 0; i < v1[x].size(); i++) {
// int son = v1[x][i];
// if (son == fa) continue;
// dfs(son, x);
// }
// }
// signed main() {
// n = read();
// for (int i = 1; i <= n; i++) score[i] = read();
// for (int i = 1; i <= n; i++) {
// int x = read(), y = read();
// v1[x].push_back(y), v1[y].push_back(x);
// }
// dfs(1, -1);
// }
#include <iostream>
#include <vector>
#include <cstring>
#include <unordered_map>
using namespace std;
#define int long long
const int N = 2510;
const int M = 100010;
int n, m, k, ans;
vector<int> v[N], v1[N];
int score[N], dist[N];
bool vis[N];
unordered_map<int, bool> visit;
int read() {
int x = 0, f = 1;
char ch = getchar();
while (ch < '0' || ch > '9') { f = (ch == '-' ? -1 : f); ch = getchar(); }
while (ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); }
return x * f;
}
void dfs(int x, int len, int n) {
if (vis[x]) return;
vis[x] = true;
if (x != n) v1[n].push_back(x);
if (!len) return;
for (int i = 0; i < v[x].size(); i++) {
int son = v[x][i];
dfs(son, len - 1, n);
}
}
void dfs2(int x, int fa, int len, int now) {
if (len == 0) {
if (x == 1) ans = max(ans, now);
return;
}
for (int i = 0; i < v1[x].size(); i++) {
int son = v1[x][i];
if (fa == son || visit[son]) continue;
visit[son] = true;
dfs2(son, x, len - 1, now + score[son]);
visit[son] = false;
}
}
signed main() {
n = read(), m = read(), k = read();
for (int i = 2; i <= n; i++) score[i] = read();
for (int i = 1; i <= m; i++) {
int x = read(), y = read();
v[x].push_back(y), v[y].push_back(x);
}
for (int i = 1; i <= n; i++) {
memset(vis, false, sizeof vis);
visit.clear();
//cout << m[10] << endl;
dfs(i, k + 1, i);
}
dfs2(1, -1, 5, 0);
cout << ans << endl;
return 0;
}