#include #include #include using namespace std; int main() { int N, M, K; cin >> N >> M >> K; vector A(N); for (int i = 0; i < N; ++i) { cin >> A[i]; } const long long INF = 1LL << 61; vector > d(N, vector(N, INF)); for (int i = 0; i < N; ++i) { d[i][i] = 0; } for (int i = 0; i < M; ++i) { int a, b; long long c; cin >> a >> b >> c; --a, --b; d[a][b] = c; d[b][a] = c; } for (int i = 0; i < N; ++i) { for (int j = 0; j < N; ++j) { for (int k = 0; k < N; ++k) { d[j][k] = min(d[j][k], d[j][i] + d[i][k]); } } } vector dp(1 << N, INF); dp[0] = 0; for (int i = 1; i < (1 << N); ++i) { for (int j = 0; j < N; ++j) { if (((i >> j) & 1) == 0) { continue; } int sub = i - (1 << j); long long cost = dp[sub] + A[j]; if (sub != 0) { long long mindist = INF; for (int k = 0; k < N; ++k) { if (((sub >> k) & 1) == 1) { mindist = min(mindist, d[j][k]); } } cost += mindist; } dp[i] = min(dp[i], cost); } } vector pop(1 << N); for (int i = 1; i < (1 << N); ++i) { pop[i] = pop[i >> 1] + (i & 1); } long long ans = INF; for (int i = 0; i < (1 << N); ++i) { if (pop[i] == K) { ans = min(ans, dp[i]); } } cout << ans << endl; return 0; }