/* Solution Author: Alexander Markov Date: 29.04.2018 */ #include #include #include #include using namespace std; const int MAXN = (int)2e5 + 5; long long cost[MAXN]; vector > g[MAXN]; int n; long long S; bool used[MAXN]; long long dfs(int u, int maxWeight) { used[u] = true; long long res = cost[u]; for (auto e: g[u]) if (!used[e.first] && e.second<=maxWeight) res = min(res, dfs(e.first, maxWeight)); return res; } bool check(int x) { for (int i=1; i<=n; i++) used[i] = false; long long res = 0; for (int u=1; u<=n; u++) if (!used[u]) res += dfs(u, x); return res <= S; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int m; cin >> n >> m >> S; for (int i=1; i<=n; i++) cin>>cost[i]; for (int i=0; i>u>>v>>w; g[u].push_back({v,w}); g[v].push_back({u,w}); } int l = 0, r = 1e9 + 2; while (l